This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.firebase.*; | |
import com.google.firebase.iid.*; | |
import com.google.firebase.messaging.*; | |
FirebaseOptions.Builder builder = new FirebaseOptions.Builder() | |
.setApplicationId("<applicationId> i.e X:XXXXXXXXXX:android:XXXXXXXXXXXXXXXXXXXXX") | |
.setApiKey("<private key>") | |
.setDatabaseUrl("https://yourFcmApp.firebaseio.com") | |
.setStorageBucket("yourFcmApp.appspot.com"); | |
FirebaseApp.initializeApp(context(), builder.build()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String token = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken(); | |
if (token != null) { | |
com.codename1.io.Preferences.set("pushKey", token); | |
your.app.namespace.SomeClass.SomeStaticMethod(token); } | |
//check token is the same after 5 seconds | |
//cn1's gcm service sometimes gets the wrong token and this is then useful to overwrite it | |
java.util.Timer timer = new java.util.Timer(); | |
timer.schedule(new java.util.TimerTask() { | |
public void run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package your.namespace; | |
import android.app.Activity; | |
import android.app.Application; | |
import android.app.NotificationManager; | |
import android.content.Context; | |
import android.os.Bundle; | |
import com.codename1.impl.android.LifecycleListener; | |
import com.codename1.impl.android.AndroidNativeUtil; | |
import java.io.BufferedOutputStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.app.NotificationManager; | |
import android.content.Intent; | |
import android.widget.Toast; | |
import android.content.Context; | |
import android.os.Bundle; | |
public class GroupsJobIntentService extends android.support.v4.app.JobIntentService { | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.groups; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Bundle; | |
public class GroupsReceiver extends BroadcastReceiver { | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.firebase.messaging.RemoteMessage; | |
import android.app.NotificationManager; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.app.PendingIntent; | |
import android.graphics.Bitmap; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.graphics.drawable.Drawable; | |
import android.support.v4.app.NotificationCompat.Builder; | |
import android.support.v4.app.NotificationCompat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getPushIntent() | |
{ | |
String actionId = null; | |
if (com.codename1.impl.android.AndroidNativeUtil.getActivity() != null){ | |
Activity activity = com.codename1.impl.android.AndroidNativeUtil.getActivity(); | |
android.os.Bundle extras = activity.getIntent().getExtras(); | |
if (extras != null) { | |
actionId = extras.getString("pushAction"); | |
extras.remove("pushAction"); | |
activity.setIntent(new Intent()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"message":{ | |
"<deviceToken>", | |
"data":{ | |
"messageType":"4", | |
"message":"title;body", | |
"notifId":"", | |
"senderId":"", | |
"hasImage":"" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//foreground notifications | |
//feel free to remove params, this is just an example that passes APN meta fields to your app | |
public static void iosActivePushReceived(String notifId, String senderId) { | |
//do stuff. don't forget to encapsulate with Display's runSerially | |
} | |
public static void registerPushFromAfterFinishedLaunching() { | |
//call your native's interfcae registePush() method from here | |
} | |
public static void iosPushReceived(String notifId) { | |
//background push tapped. You could save the notifId/flag in a static field in your app so that your app knows it has to trigger some action in start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
.h file | |
*/ | |
#import <Foundation/Foundation.h> | |
#import <UserNotifications/UserNotifications.h> | |
@interface your_namespace_YourInterfaceImpl : NSObject<UNUserNotificationCenterDelegate> { | |
} |
OlderNewer