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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ If you run into errors in combination with firebase.analytics e.g. `Error: Attem
```
to the tiapp.xml

If you register a channel with a different ID then `default` you have to add this to your `<application>` node:
```xml
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="your_channel_id"/>
```

### Setting the Notification Icon

Expand Down
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 3.3.1
version: 4.0.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: titanium-firebase-cloud-messaging
Expand Down
19 changes: 14 additions & 5 deletions android/src/firebase/cloudmessaging/CloudMessagingModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.RemoteMessage;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
Expand All @@ -34,17 +38,14 @@
import org.appcelerator.titanium.util.TiConvert;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import ti.modules.titanium.android.notificationmanager.NotificationChannelProxy;

@Kroll.module(name = "CloudMessaging", id = "firebase.cloudmessaging")
public class CloudMessagingModule extends KrollModule {

private static final String LCAT = "FirebaseCloudMessaging";
private static final String FORCE_SHOW_IN_FOREGROUND = "titanium.firebase.cloudmessaging.key";
private static CloudMessagingModule instance = null;
private static final String FORCE_SHOW_IN_FOREGROUND = "titanium.firebase.cloudmessaging.key";
private static String fcmToken = null;
private String notificationData = "";

Expand Down Expand Up @@ -76,7 +77,15 @@ private KrollDict getLastData()

if (extras != null) {
for (String key : extras.keySet()) {
data.put(key, extras.get(key));
if (extras.get(key) instanceof Bundle) {
Bundle bndl = (Bundle) extras.get(key);

for (String bdnlKey : bndl.keySet()) {
data.put(key + "_" + bdnlKey, bndl.get(bdnlKey));
}
} else {
data.put(key, extras.get(key).toString());
}
}

data.put("inBackground", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void onCreate(Bundle savedInstanceState) {

Intent launcherIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
assert launcherIntent != null;
launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
launcherIntent.addCategory(Intent.ACTION_MAIN);
launcherIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
launcherIntent.putExtra("fcm_data", notification);

Expand Down