flutterpush-notificationurbanairship.comdevicetoken

How to get Airship device token for iOS and gcm_registration_id for Android with Flutter?


I need to get Airship device token for iOS and gcm_registration_id for Android with Flutter. I can see the device token in the console (from AirshipKit I suppose) when I start the app as well as in my Airship project. But I need to get the device token in my Flutter code as it should be used there and in my Webview.

I tried to get the device token with Firebase Messaging but it returns another token, not the one from Airship.


Solution

  • To find out device token for iOS use:

    var iosToken = await FirebaseMessaging.instance.getAPNSToken();
    

    For gcm_registration_id for Android use:

    var androidToken = await FirebaseMessaging.instance.getToken();