1

In flutter I'm using Firebase In-app messaging. It says that to test my campaigns on my device I can provide a Firebase Instance ID:

enter image description here

Documentation says

Find your testing app's Instance ID by checking the Logcat in Android Studio for the following Info level log: I/FIAM.Headless: Starting InAppMessaging runtime with Instance ID YOUR_APP_ID

But I'm using Visual Code Studio to run my Flutter code. In "Debug Console" tab I do have some messages related to FIAM.Headless but nothing about "Starting InAppMessaging runtime with Instance ID YOUR_APP_ID"

How can I get the Firebase Instance IDs in Flutter?

mirkancal
  • 4,762
  • 7
  • 37
  • 75
woshitom
  • 4,811
  • 8
  • 38
  • 62
  • There are some vscode extension for logcat. https://marketplace.visualstudio.com/items?itemName=abhiagr.logcat – mirkancal Jul 03 '19 at 15:53
  • Which library are you using in flutter to use inapp messaging? flutter fire doesn't support in app messaging yet. – Umar Hussain Jul 03 '19 at 18:34
  • You don't need any flutter library, just follow the steps to install it (on android for example https://firebase.google.com/docs/in-app-messaging/get-started?authuser=1&platform=android#get_your_apps_instance_id ), additionally in app level gradle I had to add this line at the very bottom though: com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true – woshitom Jul 03 '19 at 18:41
  • @UmarHussain check this https://www.reddit.com/r/FlutterDev/comments/99bsev/exploring_firebase_inapp_messaging/ – woshitom Jul 03 '19 at 18:45

2 Answers2

2

You can get instance id token in your flutter logs as well, using firebase flutter library methods.

firebaseMessaging.getToken() returns promise which you can print and get the id. You can also listen onTokenRefresh stream and whenever token changes you can print it.

If you want to access android logcat then you can either start Android studio on your repo's android folder it will automatically pick your debug app. Or you can look for plugins which allow you to view logcat in vs code.

Umar Hussain
  • 3,461
  • 1
  • 16
  • 38
  • firebaseMessaging.getToken() gives the FCM Token which is I think different as the Instance IDs because I got this error "Invalid format. Please check the docs for retrieving the instance ID" when I copy/paste it in firebase console – woshitom Jul 03 '19 at 18:14
  • See this article for further information https://fireship.io/lessons/flutter-push-notifications-fcm-guide/, you are targeting to send notification to an individual device right? – Umar Hussain Jul 03 '19 at 18:25
  • No I'm not, I want to send an in-app message: https://firebase.google.com/docs/in-app-messaging/get-started?authuser=1&platform=android#get_your_apps_instance_id – woshitom Jul 03 '19 at 18:30
0

The Flutter extension for VS Code doesn't include anything for displaying raw logcat output like Android Studio but you can run adb logcat in the built-in Terminal to get the same output that you would in Android Studio.

Though as mentioned above, you could print the token yourself without needing to parse through the full output, something like:

firebaseMessaging.getToken().then(print);
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275
  • Hi, adb logcat did the trick thanks :) Firebase instance Id and FCM are 2 differents things though: adb logcat gave me something like eF1vOdp*** while my FCM token (which I retrieved with firebaseMessaging.getToken()) is eF1vOd***:APA91bELs7rLF7KIxw_q4Dkh26aqEzUF0_-NbNlR0wGU1csY2UhLolEjrSWzm0RCH2Uwn3kYzk4jObnuFA0zZvVL0jveFpTKnJDsyNT6T8ssjY9sB8BhvUEKYq352aIU2HwUsKgsGRUG, so actually the instance Id is the 10 first characters of the FCM, so yeah technically i could have use getToken() :) – woshitom Jul 04 '19 at 07:13
  • Aha, I wasn't entirely familiar with the library. Glad you got what you need! :-) – Danny Tuppeny Jul 04 '19 at 11:14