Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): change intent category #137

Closed
wants to merge 8 commits into from
Closed

fix(android): change intent category #137

wants to merge 8 commits into from

Conversation

m1ga
Copy link
Collaborator

@m1ga m1ga commented Feb 18, 2022

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
Copy link
Owner

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

@m1ga
Copy link
Collaborator Author

m1ga commented Feb 18, 2022

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:

  • app running in background - push arrives - didReceiveMessage is called in the app. When you click the notification the app will come to the foreground but Titanium.Android.currentActivity.intent.getStringExtra("fcm_data") is null
  • app closed - push arrives. When you click the notification the app will start and Titanium.Android.currentActivity.intent.getStringExtra("fcm_data") is filled

After this PR:

  • in both cases (app running in background or app closed) it will show the Titanium.Android.currentActivity.intent.getStringExtra("fcm_data") after clicking on the notification

@m1ga
Copy link
Collaborator Author

m1ga commented Jun 2, 2022

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
Copy link
Collaborator Author

m1ga commented Jun 10, 2022

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

@m1ga m1ga requested a review from hansemannn August 18, 2022 12:23
@hansemannn
Copy link
Owner

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
Copy link
Owner

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
Copy link
Collaborator Author

m1ga commented Mar 21, 2023

closed in favor of #147

@m1ga m1ga closed this Mar 21, 2023
@m1ga m1ga deleted the fixLauncher branch March 28, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants