Skip to content

Messaging: deleteToken no longer deletes token correctly #8491

@helenaford

Description

@helenaford

Step 0: Are you in the right place?

  • For issues or feature requests related to the code in this repository
    file a Github issue.
    • If this is a feature request please use the Feature Request template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general (non-iOS) Firebase discussion, use the firebase-talk
    google group.
  • For backend issues, console issues, and other non-SDK help that does not fall under one
    of the above categories, reach out to
    Firebase Support.
  • Once you've read this section and determined that your issue is appropriate for
    this repository, please delete this section.

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.5
  • Firebase SDK version: 8.5.0
  • Installation method: CocoaPods (select one)
  • Firebase Component: Messaging (Auth, Core, Database, Firestore, Messaging, Storage, etc)

[REQUIRED] Step 2: Describe the problem

FlutterFire: Issue: firebase/flutterfire#6766
RNFB: Issue invertase/react-native-firebase#5570 P/R invertase/react-native-firebase#5571

Steps to reproduce:

Call deleteTokenWithCompletion and inspect the token from tokenWithCompletion and see that it has not changed and is still valid.

From debugging, I can see that when the installations id is refreshed via installations.deleteWithCompletion, the token will always refresh when calling messaging.deleteTokenWithCompletion

This behaviour can be replicated both in FlutterFire and RNFB. My question is what is the correct solution/method to refresh an FCM token?

I've looked through the changelog and the documentation, and it's still not 100% clear to me on how the installations id should be managed in relation to the FCM token.

Any help or guidance on this would be greatly appreciated.

Relevant Code:

By changing the following code, additional requests to deleteTokenWithCompletion will refresh the token:
From:

[[FIRMessaging messaging] deleteTokenWithCompletion:^(NSError *_Nullable error) {
    if (error) {
      [RNFBSharedUtils rejectPromiseWithNSError:reject error:error];
    } else {
      resolve([NSNull null]);
    }
  }];

To:

[[FIRInstallations installations] deleteWithCompletion:^(NSError * _Nullable error) {
    if (error) {
      [RNFBSharedUtils rejectPromiseWithNSError:reject error:error];
    } else {
      resolve([NSNull null]);
    }
  }];

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions