Repository navigation
Replies: 1 comment
|
In 1. Physical Device RequirediOS simulators do not support APNS tokens unless you are running on macOS 13+ with iOS 16+ simulator and full Apple Developer signing. If testing on older iOS versions (iOS 13-15), a physical iOS device is required. 2. Request Notification Permissions FirstOn iOS, the APNs token will not be generated until notification permissions have been requested and granted: FirebaseMessaging messaging = FirebaseMessaging.instance;
NotificationSettings settings = await messaging.requestPermission(
alert: true,
badge: true,
sound: true,
);
if (settings.authorizationStatus == AuthorizationStatus.authorized) {
// Wait briefly for APNS registration callback
String? apnsToken = await messaging.getAPNSToken();
print('APNS Token: $apnsToken');
String? fcmToken = await messaging.getToken();
print('FCM Token: $fcmToken');
}3. Xcode Capabilities ChecklistOpen
4. Retry loop for APNS tokenOn initial startup, APNS token generation is asynchronous: // Poll with a brief timeout if token is null immediately after requestPermission
String? apnsToken;
for (int i = 0; i < 5; i++) {
apnsToken = await FirebaseMessaging.instance.getAPNSToken();
if (apnsToken != null) break;
await Future.delayed(const Duration(seconds: 1));
} |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I am currently working on a Flutter project that includes the firebase_messaging package version ^14.7.20 and firebase_core package version ^2.27.1. According to the official Firebase documentation, push messages can be received successfully on Android without any issues. However, there seems to be a problem with iOS versions 13 or above as they are unable to retrieve the APNSToken and consequently cannot receive push messages.
All reactions