Reputation: 58
I'm writing an app with the intent of using Azure Notification Hubs. I've been following several of the online examples to get the Android assembly wired up first. The only difference is the name of my classes, for example I use FirebaseIIDService instead of "MyFirebaseIIDService" or whatever. It derives from FirebaseInstanceIdService and has the attributes shown in the examples:
[Service]
[IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
My override of OnTokenRefresh() is never called. In MainActivity.OnCreate() my Intent.Extras is NULL (I'm assuming it should contain the Intents for messaging, but perhaps that's incorrect.)
The google-services.json is there, the Android Manifest has been updated:
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
I swear this was working at one point. What could possibly be wrong? Many thanks in advance.
Upvotes: 0
Views: 710
Reputation: 58
So reading more about this, it appears this section of code is only hit when the application is installed, or if the token is invalidated. You can put a block of code inside your MainActivity.OnCreate() method to invalidate the token. This triggers a refresh. Example:
#if DEBUG
Task.Run(() =>
{
FirebaseInstanceId.Instance.DeleteInstanceId();
Log.Debug(TAG, "Forced token: " + FirebaseInstanceId.Instance.Token);
});
#endif
Upvotes: 1