Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(messaging, ios): remove dummy APNS token for simulator #13570

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented Oct 30, 2024

Description

It seems an APNS token is already received/set for iOS simulator and we no longer need to set a dummy APNS token.

Tested on iOS 17 and 18.

Related Issues

fixes #13558

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@russellwheatley russellwheatley changed the title fix(messaging, ios): remove fake APNS token for simulator fix(messaging, ios): remove dummy APNS token for simulator Oct 30, 2024
@ziwen-li
Copy link

@russellwheatley I tested on iOS 18.1 simulator, it works fine. Thanks for your work.

@daniel-carr-3000
Copy link

Came here just to say I was also running into this issue. This PR resolves it for me using the iOS 18.1 Simulator.

@MuhammedOzdogan
Copy link

MuhammedOzdogan commented Nov 3, 2024

Hi @daniel-carr-3000 ,
How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

@daniel-carr-3000
Copy link

Hi @daniel-carr-3000 , How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

I set firebase_messaging to this branch:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

@EssaJMahmood
Copy link

Hi @daniel-carr-3000 , How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

I set firebase_messaging to this branch:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

I can confirm this solved my problem, what I did was change the firebase_messaging to the branch and Podfile.lock, then pod install in the IOS directory, and then I ran my application, and this fixed my problem

@Yusufkulcu
Copy link

MERHABA@daniel-carr-3000, Hiçbir sorun olmadan çalıştırmayı nasıl başardın? Bu düzeltme flutterfire için ve pubspec.yaml'ımı kontrol ettim. Flutterfire bağımlılığım yok. flutterfire configureUygulama dizininde sıfırdan mı çalıştırdın?

firebase_messaging'i şu dala ayarladım:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

Bunun sorunumu çözdüğünü doğrulayabilirim, yaptığım şey firebase_messaging'i Podfile.lock şubesine değiştirmek, ardından IOS dizininde pod install yapmak ve ardından uygulamamı çalıştırmaktı ve bu sorunumu çözdü

Hi @daniel-carr-3000 , How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

I set firebase_messaging to this branch:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

I can confirm this solved my problem, what I did was change the firebase_messaging to the branch and Podfile.lock, then pod install in the IOS directory, and then I ran my application, and this fixed my problem

Could you please explain the solution in detail. I'm new to Flutter and I'm having the same problem. I don't know how to solve it either. I would be very glad if you could explain it with pictures

@Yusufkulcu
Copy link

Hi @daniel-carr-3000 , How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

I set firebase_messaging to this branch:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

Could you please explain the solution in detail. I'm new to Flutter and I'm having the same problem. I don't know how to solve it either. I would be very glad if you could explain it with pictures

@EssaJMahmood
Copy link

EssaJMahmood commented Nov 7, 2024

MERHABA@daniel-carr-3000, Hiçbir sorun olmadan çalıştırmayı nasıl başardın? Bu düzeltme flutterfire için ve pubspec.yaml'ımı kontrol ettim. Flutterfire bağımlılığım yok. flutterfire configureUygulama dizininde sıfırdan mı çalıştırdın?

firebase_messaging'i şu dala ayarladım:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

Bunun sorunumu çözdüğünü doğrulayabilirim, yaptığım şey firebase_messaging'i Podfile.lock şubesine değiştirmek, ardından IOS dizininde pod install yapmak ve ardından uygulamamı çalıştırmaktı ve bu sorunumu çözdü

Hi @daniel-carr-3000 , How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

I set firebase_messaging to this branch:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

I can confirm this solved my problem, what I did was change the firebase_messaging to the branch and Podfile.lock, then pod install in the IOS directory, and then I ran my application, and this fixed my problem

Could you please explain the solution in detail. I'm new to Flutter and I'm having the same problem. I don't know how to solve it either. I would be very glad if you could explain it with pictures

MERHABA@daniel-carr-3000, Hiçbir sorun olmadan çalıştırmayı nasıl başardın? Bu düzeltme flutterfire için ve pubspec.yaml'ımı kontrol ettim. Flutterfire bağımlılığım yok. flutterfire configureUygulama dizininde sıfırdan mı çalıştırdın?

firebase_messaging'i şu dala ayarladım:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

Bunun sorunumu çözdüğünü doğrulayabilirim, yaptığım şey firebase_messaging'i Podfile.lock şubesine değiştirmek, ardından IOS dizininde pod install yapmak ve ardından uygulamamı çalıştırmaktı ve bu sorunumu çözdü

Hi @daniel-carr-3000 , How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

I set firebase_messaging to this branch:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

I can confirm this solved my problem, what I did was change the firebase_messaging to the branch and Podfile.lock, then pod install in the IOS directory, and then I ran my application, and this fixed my problem

Could you please explain the solution in detail. I'm new to Flutter and I'm having the same problem. I don't know how to solve it either. I would be very glad if you could explain it with pictures

hi ok, the problem is caused by firebase_messaging for me it was a problem related to generate FCM token(the token that we use in firebase cloud messaging to send notification to a specific user), in my application i generate the token this way

    try{
      if (Platform.isIOS || Platform.isMacOS) {
        final apnsToken = await FirebaseMessaging.instance.getAPNSToken();
        if(apnsToken != null){
          deviceToken = await FirebaseMessaging.instance.getToken();
        }
      } else {
        deviceToken = await FirebaseMessaging.instance.getToken();
      }
    }
    catch (e){

    }

it was working and didn't have any problem in the past month then suddenly it stopped working so I first updated the firebase_messaging package as in the previous comments and set the source of the package to the provided one, `

firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

place this in your pubspace.yaml file, and if there was any other firebase_messaging package in the pubspace.yaml remove it, then run

flutter clean
flutter pub get
cd ios 
rm podfile.lock
pod install
cd ../
flutter run 

then the problem is solved. If you are not using the latest Flutter version, upgrade to the newest version by running flutter upgrade, then at flutter pub get step, you cloud have a conflict of dependence, for example, firebase_messaging requires a newer version of firebase_core, and another package requires an older version of firebase_core this is normal, and you just need to update those packages to a newer version

@Lyokone Lyokone merged commit 17dfff1 into main Nov 7, 2024
27 of 29 checks passed
@Lyokone Lyokone deleted the messaging-13558 branch November 7, 2024 07:53
@Yusufkulcu
Copy link

MERHABA@daniel-carr-3000, Hiçbir sorun olmadan çalıştırmayı nasıl başardın? Bu düzeltme flutterfire için ve pubspec.yaml'ımı kontrol ettim. Flutterfire bağımlılığım yok. flutterfire configureUygulama dizininde sıfırdan mı çalıştırdın?

firebase_messaging'i şu dala ayarladım:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

Bunun sorunumu çözdüğünü doğrulayabilirim, yaptığım şey firebase_messaging'i Podfile.lock şubesine değiştirmek, ardından IOS dizininde pod install yapmak ve ardından uygulamamı çalıştırmaktı ve bu sorunumu çözdü

Hi @daniel-carr-3000 , How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

I set firebase_messaging to this branch:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

I can confirm this solved my problem, what I did was change the firebase_messaging to the branch and Podfile.lock, then pod install in the IOS directory, and then I ran my application, and this fixed my problem

Could you please explain the solution in detail. I'm new to Flutter and I'm having the same problem. I don't know how to solve it either. I would be very glad if you could explain it with pictures

MERHABA@daniel-carr-3000, Hiçbir sorun olmadan çalıştırmayı nasıl başardın? Bu düzeltme flutterfire için ve pubspec.yaml'ımı kontrol ettim. Flutterfire bağımlılığım yok. flutterfire configureUygulama dizininde sıfırdan mı çalıştırdın?

firebase_messaging'i şu dala ayarladım:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

Bunun sorunumu çözdüğünü doğrulayabilirim, yaptığım şey firebase_messaging'i Podfile.lock şubesine değiştirmek, ardından IOS dizininde pod install yapmak ve ardından uygulamamı çalıştırmaktı ve bu sorunumu çözdü

Hi @daniel-carr-3000 , How did you manage to run without any issue. This fix is for flutterfire and I checked my pubspec.yaml. I don't have flutterfire dependency. Did you run flutterfire configure in the app directory from scratch?

I set firebase_messaging to this branch:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      path: packages/firebase_messaging/firebase_messaging
      ref: messaging-13558

I can confirm this solved my problem, what I did was change the firebase_messaging to the branch and Podfile.lock, then pod install in the IOS directory, and then I ran my application, and this fixed my problem

Could you please explain the solution in detail. I'm new to Flutter and I'm having the same problem. I don't know how to solve it either. I would be very glad if you could explain it with pictures

hi ok, the problem is caused by firebase_messaging for me it was a problem related to generate FCM token(the token that we use in firebase cloud messaging to send notification to a specific user), in my application i generate the token this way

    try{
      if (Platform.isIOS || Platform.isMacOS) {
        final apnsToken = await FirebaseMessaging.instance.getAPNSToken();
        if(apnsToken != null){
          deviceToken = await FirebaseMessaging.instance.getToken();
        }
      } else {
        deviceToken = await FirebaseMessaging.instance.getToken();
      }
    }
    catch (e){

    }

it was working and didn't have any problem in the past month then suddenly it stopped working so I first updated the firebase_messaging package as in the previous comments and set the source of the package to the provided one, `

firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

place this in your pubspace.yaml file, and if there was any other firebase_messaging package in the pubspace.yaml remove it, then run

flutter clean
flutter pub get
cd ios 
rm podfile.lock
pod install
cd ../
flutter run 

then the problem is solved. If you are not using the latest Flutter version, upgrade to the newest version by running flutter upgrade, then at flutter pub get step, you cloud have a conflict of dependence, for example, firebase_messaging requires a newer version of firebase_core, and another package requires an older version of firebase_core this is normal, and you just need to update those packages to a newer version

image

@daniel-carr-3000
Copy link

@Yusufkulcu this has been merged in and is part of firebase_messaging v15.1.4.

Change your pubspec.yaml to:

firebase_messaging: ^15.1.4

then run flutter pub get

@Yusufkulcu
Copy link

@Yusufkulcu this has been merged in and is part of firebase_messaging v15.1.4.

Change your pubspec.yaml to:

firebase_messaging: ^15.1.4

then run flutter pub get

okey, thank you. Also have a new error

image

@Yusufkulcu
Copy link

@daniel-carr-3000

image

my pubspec file

@Yusufkulcu
Copy link

image

@Yusufkulcu
Copy link

problem is solved

@ziqq
Copy link

ziqq commented Nov 11, 2024

Not working.

[firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling `getAPNSToken()`.

@zamvar
Copy link

zamvar commented Nov 11, 2024

@ziqq if this is the error message youre getting please double check if you haved uploaded an APNS key on your firebase console. once youve uploade the APNS key delete the old GoogleServices.plist and reconfigure using flutterfire command.

@ziqq
Copy link

ziqq commented Nov 11, 2024

@ziqq if this is the error message youre getting please double check if you haved uploaded an APNS key on your firebase console.

Naturally, the app worked without problems until last week.

image image

@Yusufkulcu
Copy link

Update the flutter_message library. The current version has been released, vr problem has been solved.

@ziqq
Copy link

ziqq commented Nov 11, 2024

Update the flutter_message library. The current version has been released, vr problem has been solved.

I upgraded it.

@ziqq
Copy link

ziqq commented Nov 11, 2024

I tried and tried and tried and finally I think I got a FCM token. Solved. My VPN was a problem.

@vfxbro
Copy link

vfxbro commented Nov 11, 2024

uploaded APN keys to Firebase and updated the GoogleServices.plist file

I still get the error:

FirebaseException ([firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling getAPNSToken().)

IOS 16.2 Emulator

firebase_messaging: ^15.1.4
firebase_core: ^3.7.0

Снимок экрана 2024-11-11 в 22 20 26

@vfxbro
Copy link

vfxbro commented Nov 11, 2024

When I write String? token = await _firebaseMessaging.getAPNSToken();

instead of String? token = await _firebaseMessaging.getToken();

then I get the same error

Снимок экрана 2024-11-11 в 23 08 34

@lflorent
Copy link

lflorent commented Dec 5, 2024

Hi @russellwheatley thanks for this fix.

It doesn't work on iOS 15.5 simulator but it does on iOS 16.x, 17.x, 18.x simulators. See my comment here .

@firebase firebase locked and limited conversation to collaborators Dec 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

firebase_messaging/iOS: Invalid fetch response, expected 'token' or 'Error' key