firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.7k stars 3.97k forks source link

πŸ› [firebase_messaging] "deleteToken" does not invalidate APNS tokens on iOS #11849

Closed tpucci closed 11 months ago

tpucci commented 11 months ago

Bug report

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a new app
  2. Launch it on a real iOS device
  3. Run the following
    
    await FirebaseMessaging.instance.requestPermission(
              sound: true,
              badge: true,
              alert: true,
              provisional: false,
            );

final a = await FirebaseMessaging.instance.getAPNSToken(); await FirebaseMessaging.instance.deleteToken(); final b = await FirebaseMessaging.instance.getAPNSToken(); assert(a != b)


### Expected behavior

Token should be renewed.

---

### Flutter doctor

Run `flutter doctor` and paste the output below:

<details><summary>Click To Expand</summary>

Doctor summary (to see all details, run flutter doctor -v): [βœ“] Flutter (Channel stable, 3.13.7, on macOS 13.6 22G120 darwin-arm64, locale en-FR) [βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [βœ“] Xcode - develop for iOS and macOS (Xcode 15.0.1) [βœ“] Chrome - develop for the web [βœ“] Android Studio (version 2022.3) [βœ“] IntelliJ IDEA Ultimate Edition (version 2023.2.3) [βœ“] IntelliJ IDEA Community Edition (version 2023.1.4) [βœ“] VS Code (version 1.84.0) [βœ“] Connected device (4 available) [βœ“] Network resources

β€’ No issues found!


</details>

---

### Flutter dependencies

Run `flutter pub deps -- --style=compact` and paste the output below:

<details><summary>Click To Expand</summary>

Dart SDK 3.1.3 Flutter SDK 3.13.7 app 1.0.0+1

dependencies:

dev dependencies:

transitive dependencies:


danagbemava-nc commented 11 months ago

Hi @tpucci, the FirebaseMessaging.instance.deleteToken() method does not delete the APNs token. It deletes the FCM token.

See https://firebase.google.com/docs/reference/ios/firebasemessaging/api/reference/Classes/FIRMessaging#-deletetokenwithcompletion:

If you call FirebaseMessaging.instance.getToken() and then call FirebaseMessaging.instance.deleteToken() you do get a new token. I don't think you can delete the APNs token with the firebase methods.

Is there any reason you'd want to delete the APNS token from within the app rather than the FCM token?

tpucci commented 11 months ago

Hi @danagbemava-nc ! Thanks for you answer !

I use a third-party (Sendbird) that rely on APNS token for iOS (and they do not integrate with FCM). On logout, I would like to invalidate APNS token πŸ™‚

I thought deleteToken would delete the APNS token as well.

Feel free to close the issue if it is not relevant πŸ™‚

danagbemava-nc commented 11 months ago

Hi @tpucci, unfortunately, there doesn't seem to be a way to invalidate the APNS token (not that I have found anyway). It appears to be unique for each device per app.

This appears to be out of scope for this repo so I'll be closing this.

Thank you