How to get iOS device token in flutter app
I need to get device token from the ios app to register it with zendesk app.
func application(application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("X__APNS: \(String(describing: deviceToken))")
}
But in ios app this method is not triggering only this method is triggering
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?)
{
print("Firebase registration token: \(String(describing: fcmToken))")
Chat.registerPushTokenString(fcmToken ?? "")
}
I tried to get that token via the flutter app using firebase messenging
await FirebaseMessaging.instance.getToken().then((value) async {
var token = value ?? '';
print(token);
});
await FirebaseMessaging.instance.getAPNSToken().then((value) async {
var token = value ?? '';
});
but both methods are not helping to get the ios device token in flutter. Is the APNS token equal to the device token ?
Yes, APNS token for iOS is same as default token, you can get it by using,
FirebaseMessaging.instance.getToken().then((token) {
print('This is Token: ' '${token}');
});