Open tushaagit opened 1 month ago
same here for iOS (tested with iOS 16.2 and 17.2):
code:
cordova.plugins.firebase.messaging.requestPermission().then(function () {
console.log("messaging permission granted");
cordova.plugins.firebase.messaging.getToken().then(function (token) {
console.log("Got device token:", token);
window.fcmToken = token;
}).catch(error => {
console.error("Failed to get token:", error);
});
}).catch(function (error) {
console.error("Permission denied:", error);
});
logs:
messaging permission granted Failed to get token: The operation couldn’t be completed. No APNS token specified before fetching FCM Token
when I call messaging.getToken("apns-buffer") or messaging.getToken("apns-string") before calling messaging.getToken() both resolve to null, and the subsequent call to getToken() causes the same error.
Ok. Messaging does not work on iOS Simulator only on a real device. Why Apple whyyy ...
If you are on a real device you may need to add this to your config.xml.
<config-file platform="ios" target="*-Info.plist" parent="UIBackgroundModes">
<array>
<string>remote-notification</string>
</array>
</config-file>
Getting Error: APNS device token not set before retrieving FCM Token for Sender ID '1040730720947'.Be sure to re-retrieve the FCM token once the APNS device token is set.
Getting above issue on Cordova hybrid ios app while subscribing to topic.
Taken care of following things: 1] Latest firebase messaging app is installed, 2] Firebase notification permission taken from user 3] provisioning profile, certificates and APNS key is set properly in Apple profile.
Still this error is coming. Please suggest if any solution is available for this issue?