hansemannn / titanium-firebase-cloud-messaging

Use the Firebase Cloud Messaging SDK in Axway Titanium 🚀 Edit
Other
43 stars 31 forks source link

fix(android): change intent category #137

Closed m1ga closed 1 year ago

m1ga commented 2 years ago

Change the launcher category from Intent.CATEGORY_LAUNCHER to Intent.ACTION_MAIN. This will trigger

var message = Titanium.Android.currentActivity.intent.getStringExtra("fcm_data");
console.log("intent string extra: ", message);

when the app was in the background (still running) and you click on the notification. Before it was empty unless the app was closed.

firebase.cloudmessaging-android-4.0.0.zip

hansemannn commented 2 years ago

Are there any side effects / regression that this could cause? I'm very cautious these days 👍

m1ga commented 2 years ago

I'm still testing why this is like this.

The default category (printing launcherIntent.getCategories() here) is {android.intent.category.LAUNCHER} and I add an action to the category so it looks like this: {android.intent.action.MAIN, android.intent.category.LAUNCHER}.

I'm not sure why the ACTION in the category works and just leaving it at the defaults won't.

Before this PR:

After this PR:

m1ga commented 2 years ago

When there is a gcm.n.analytics_data field in the notification there was an error: ERROR] JNIUtil: !!! Unable to convert unknown Java object class ‘android.os.Bundle’ to JS value !!! when reading the lastData property. That property contains a Bundle and not just a value. I've mapped that to

[INFO]  'gcm.n.analytics_data_from': '47582xxxx',
[INFO]  'gcm.n.analytics_data_google.c.a.e': '1',

now.

m1ga commented 2 years ago

Added toString() for the return values. That will fix e.g. a problem in combination with ti.nfc. The FCM module will read the NFC intent and can't handle that data. With toString() it won't crash anymore. Might also happen with other modules that call the app via Intent

hansemannn commented 2 years ago

This looks like a change in app behavior, forcing this to be a major update, e.g. 4.0.0. And it would be great to have some more external testing on this before merging.

hansemannn commented 2 years ago

Fine to merge after we get the 3.x releases with the open patches out. Then we have these changes available to both users (3.x and 4x users).

m1ga commented 1 year ago

closed in favor of https://github.com/hansemannn/titanium-firebase-cloud-messaging/pull/147