From db965b0005a79865d0e59096a242cb80413da7fa Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Mon, 16 Jan 2017 14:27:14 +0100 Subject: [PATCH 01/92] Typ-o manully --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fca09752e..07bda846e 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ $ npm install react-native-notifications --save ### iOS -First, [Manully link](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking) the library to your Xcode project. +First, [Manually link](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking) the library to your Xcode project. Then, to enable notifications support add the following line at the top of your `AppDelegate.m` From 4452be90486dfc6ec96db5774d5cbdc0a7259dc4 Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Mon, 16 Jan 2017 17:35:20 +0100 Subject: [PATCH 02/92] Expose registration failure event --- README.md | 17 +++++++++++++++++ RNNotifications/RNNotifications.h | 1 + RNNotifications/RNNotifications.m | 17 +++++++++++++++++ index.ios.js | 7 +++++++ test/index.ios.spec.js | 1 + 5 files changed, 43 insertions(+) diff --git a/README.md b/README.md index fca09752e..eee4ebac2 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,10 @@ And the following methods to support registration and receiving notifications: [RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } +- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { + [RNNotifications didFailToRegisterForRemoteNotificationsWithError:error]; +} + // Required for the notification event. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification { [RNNotifications didReceiveRemoteNotification:notification]; @@ -151,16 +155,29 @@ import NotificationsIOS from 'react-native-notifications'; class App extends Component { constructor() { NotificationsIOS.addEventListener('remoteNotificationsRegistered', this.onPushRegistered.bind(this)); + NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', this.onPushRegistrationFaled.bind(this)); NotificationsIOS.requestPermissions(); } onPushRegistered(deviceToken) { console.log("Device Token Received", deviceToken); } + + onPushRegistrationFailed(error) { + // For example: + // + // error={ + // domain: 'NSCocoaErroDomain', + // code: 3010, + // localizedDescription: 'remote notifications are not supported in the simulator' + // } + console.error(error); + } componentWillUnmount() { // prevent memory leaks! NotificationsIOS.removeEventListener('remoteNotificationsRegistered', this.onPushRegistered.bind(this)); + NotificationsIOS.removeEventListener('remoteNotificationsRegistrationFailed', this.onPushRegistrationFailed.bind(this)); } } diff --git a/RNNotifications/RNNotifications.h b/RNNotifications/RNNotifications.h index fb97dc0fa..f72b424e9 100644 --- a/RNNotifications/RNNotifications.h +++ b/RNNotifications/RNNotifications.h @@ -6,6 +6,7 @@ @interface RNNotifications : NSObject + (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; ++ (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; + (void)didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings; + (void)didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type; diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index 47427862c..1f8f90610 100644 --- a/RNNotifications/RNNotifications.m +++ b/RNNotifications/RNNotifications.m @@ -12,6 +12,7 @@ NSString* const RNNotificationClearAction = @"CLEAR"; NSString* const RNNotificationsRegistered = @"RNNotificationsRegistered"; +NSString* const RNNotificationsRegistrationFailed = @"RNNotificationsRegistrationFailed"; NSString* const RNPushKitRegistered = @"RNPushKitRegistered"; NSString* const RNNotificationReceivedForeground = @"RNNotificationReceivedForeground"; NSString* const RNNotificationReceivedBackground = @"RNNotificationReceivedBackground"; @@ -118,6 +119,11 @@ - (void)setBridge:(RCTBridge *)bridge name:RNNotificationsRegistered object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(handleNotificationsRegistrationFailed:) + name:RNNotificationsRegistrationFailed + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePushKitRegistered:) name:RNPushKitRegistered @@ -164,6 +170,12 @@ + (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken userInfo:@{@"deviceToken": [self deviceTokenToString:deviceToken]}]; } ++ (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { + [[NSNotificationCenter defaultCenter] postNotificationName:RNNotificationsRegistrationFailed + object:self + userInfo:@{@"code": [NSNumber numberWithInteger:error.code], @"domain": error.domain, @"localizedDescription": error.localizedDescription}]; +} + + (void)didReceiveRemoteNotification:(NSDictionary *)notification { UIApplicationState state = [UIApplication sharedApplication].applicationState; @@ -389,6 +401,11 @@ - (void)handleNotificationsRegistered:(NSNotification *)notification [_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationsRegistered" body:notification.userInfo]; } +- (void)handleNotificationsRegistrationFailed:(NSNotification *)notification +{ + [_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationsRegistrationFailed" body:notification.userInfo]; +} + - (void)handlePushKitRegistered:(NSNotification *)notification { [_bridge.eventDispatcher sendDeviceEventWithName:@"pushKitRegistered" body:notification.userInfo]; diff --git a/index.ios.js b/index.ios.js index 3bbf07298..6dd788fd3 100644 --- a/index.ios.js +++ b/index.ios.js @@ -10,6 +10,7 @@ const NativeRNNotifications = NativeModules.RNNotifications; // eslint-disable-l import IOSNotification from "./notification.ios"; export const DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT = "remoteNotificationsRegistered"; +export const DEVICE_REMOTE_NOTIFICATIONS_REGISTRATION_FAILED_EVENT = "remoteNotificationsRegistrationFailed"; export const DEVICE_PUSH_KIT_REGISTERED_EVENT = "pushKitRegistered"; export const DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT = "notificationReceivedForeground"; export const DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT = "notificationReceivedBackground"; @@ -19,6 +20,7 @@ const DEVICE_NOTIFICATION_ACTION_RECEIVED = "notificationActionReceived"; const _exportedEvents = [ DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT, + DEVICE_REMOTE_NOTIFICATIONS_REGISTRATION_FAILED_EVENT, DEVICE_PUSH_KIT_REGISTERED_EVENT, DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT, DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT, @@ -62,6 +64,11 @@ export default class NotificationsIOS { DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT, registration => handler(registration.deviceToken) ); + } else if (type === DEVICE_REMOTE_NOTIFICATIONS_REGISTRATION_FAILED_EVENT) { + listener = DeviceEventEmitter.addListener( + DEVICE_REMOTE_NOTIFICATIONS_REGISTRATION_FAILED_EVENT, + error => handler(error) + ); } else if (type === DEVICE_PUSH_KIT_REGISTERED_EVENT) { listener = DeviceEventEmitter.addListener( DEVICE_PUSH_KIT_REGISTERED_EVENT, diff --git a/test/index.ios.spec.js b/test/index.ios.spec.js index c9cdd8206..2ba23fb41 100644 --- a/test/index.ios.spec.js +++ b/test/index.ios.spec.js @@ -9,6 +9,7 @@ describe("NotificationsIOS", () => { let deviceEvents = [ "pushKitRegistered", "remoteNotificationsRegistered", + "remoteNotificationsRegistrationFailed", "notificationReceivedForeground", "notificationReceivedBackground", "notificationOpened" From 6cb7dd1948e760bf725ba0f1af1aa09ffbacdedf Mon Sep 17 00:00:00 2001 From: Lidan Hifi Date: Tue, 17 Jan 2017 22:14:06 +0200 Subject: [PATCH 03/92] 1.1.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b376c5faf..45f772ed4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.1.5", + "version": "1.1.6", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From 89ba511e876b05271ccb7bd62f1e63292482e2ca Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Fri, 20 Jan 2017 21:38:59 +0100 Subject: [PATCH 04/92] Typ-o regsitered --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 275b61da5..851fe52e0 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ import {NotificationsAndroid} from 'react-native-notifications'; // On Android, we allow for only one (global) listener per each event type. NotificationsAndroid.setRegistrationTokenUpdateListener((deviceToken) => { - console.log('Push-notifications regsitered!', deviceToken) + console.log('Push-notifications registered!', deviceToken) }); ``` From 7cbf9f653edc7e10060e80d3228a89c2507449d2 Mon Sep 17 00:00:00 2001 From: Amit Davidi Date: Mon, 23 Jan 2017 13:15:07 +0200 Subject: [PATCH 05/92] Issue #21: Change getInitialNotification() to work like iOS when no notif is available --- README.md | 9 +++++---- example/index.android.js | 2 +- index.android.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 275b61da5..42cfeec46 100644 --- a/README.md +++ b/README.md @@ -103,10 +103,11 @@ import com.wix.reactnativenotifications.RNNotificationsPackage; @Override protected List getPackages() { - return Arrays.asList( - new MainReactPackage(), - ... - new RNNotificationsPackage(MainApplication.this), + return Arrays.asList( + new MainReactPackage(), + // ... + new RNNotificationsPackage(MainApplication.this) + ); ``` ### Receiving push notifications diff --git a/example/index.android.js b/example/index.android.js index 24274b15a..5681d187c 100644 --- a/example/index.android.js +++ b/example/index.android.js @@ -89,7 +89,7 @@ class MainComponent extends Component { componentDidMount() { console.log('ReactScreen', 'componentDidMount'); PendingNotifications.getInitialNotification() - .then((notification) => {console.log("getInitialNotification:", notification); this.setState({initialNotification: notification.getData()});}) + .then((notification) => {console.log("getInitialNotification:", notification); this.setState({initialNotification: (notification ? notification.getData() : undefined)});}) .catch((err) => console.error("getInitialNotifiation failed", err)); } diff --git a/index.android.js b/index.android.js index 4d3bca1b2..03fbe0d45 100644 --- a/index.android.js +++ b/index.android.js @@ -60,7 +60,7 @@ export class PendingNotifications { static getInitialNotification() { return RNNotifications.getInitialNotification() .then((rawNotification) => { - return new NotificationAndroid(rawNotification); + return rawNotification ? new NotificationAndroid(rawNotification) : undefined; }); } } From 89620c490daacd85dd7ae343d537350d95c601d4 Mon Sep 17 00:00:00 2001 From: Lidan Hifi Date: Mon, 23 Jan 2017 15:49:13 +0200 Subject: [PATCH 06/92] 1.1.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 45f772ed4..0d14c9461 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.1.6", + "version": "1.1.7", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From a83c578c9856d791cc70083161862b276a43c432 Mon Sep 17 00:00:00 2001 From: Amit Davidi Date: Wed, 15 Feb 2017 16:56:31 +0200 Subject: [PATCH 07/92] Fix broken android API test --- test/index.android.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/index.android.spec.js b/test/index.android.spec.js index d47173755..a41255b81 100644 --- a/test/index.android.spec.js +++ b/test/index.android.spec.js @@ -181,13 +181,13 @@ describe("Notifications-Android > ", () => { .catch((err) => done(err)); }); - it("should return empty notification data if not available", (done) => { + it("should return empty notification if not available", (done) => { expect(getInitialNotificationStub).to.not.have.been.called; getInitialNotificationStub.returns(Promise.resolve(null)); libUnderTest.PendingNotifications.getInitialNotification() .then((notification) => { - expect(notification.getData()).to.equal(null); + expect(notification).to.be.undefined; done(); }) .catch((err) => done(err)); From c0227c5418385a6faa79a68d6a63ef17bf219b62 Mon Sep 17 00:00:00 2001 From: sportnak Date: Wed, 1 Mar 2017 17:26:21 -0800 Subject: [PATCH 08/92] Update README.md Fix improper reference in readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60bb5171a..1f1fc3278 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ import NotificationsIOS from 'react-native-notifications'; class App extends Component { constructor() { NotificationsIOS.addEventListener('remoteNotificationsRegistered', this.onPushRegistered.bind(this)); - NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', this.onPushRegistrationFaled.bind(this)); + NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', this.onPushRegistrationFailed.bind(this)); NotificationsIOS.requestPermissions(); } From 53df690c90d279d16f06f861bb6b07748b9166cf Mon Sep 17 00:00:00 2001 From: Amit Davidi Date: Tue, 7 Mar 2017 12:54:37 +0200 Subject: [PATCH 09/92] Add the (unprotected) VIBRATE permission on Android to support vibration on old devices --- android/src/main/AndroidManifest.xml | 3 +++ .../wix/reactnativenotifications/app/MainActivity.java | 5 ++++- .../src/main/res/layout/activity_main.xml | 3 ++- .../src/main/res/layout/activity_main_prelollipop.xml | 10 ++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 example/android/myapplication/src/main/res/layout/activity_main_prelollipop.xml diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 8061e77c1..143347523 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -11,6 +11,9 @@ android:protectionLevel="signature" /> + + + - - - - - - - - - + android:name=".gcm.FcmInstanceIdListenerService"> - - - - - - - + + + diff --git a/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java b/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java index 33a13bf94..8a85a6bed 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java +++ b/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java @@ -23,7 +23,7 @@ import com.wix.reactnativenotifications.core.notification.PushNotificationProps; import com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer; import com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer; -import com.wix.reactnativenotifications.gcm.GcmInstanceIdRefreshHandlerService; +import com.wix.reactnativenotifications.gcm.FcmInstanceIdRefreshHandlerService; import static com.wix.reactnativenotifications.Defs.LOGTAG; @@ -47,7 +47,7 @@ public String getName() { @Override public void initialize() { Log.d(LOGTAG, "Native module init"); - startGcmIntentService(GcmInstanceIdRefreshHandlerService.EXTRA_IS_APP_INIT); + startGcmIntentService(FcmInstanceIdRefreshHandlerService.EXTRA_IS_APP_INIT); final IPushNotificationsDrawer notificationsDrawer = PushNotificationsDrawer.get(getReactApplicationContext().getApplicationContext()); notificationsDrawer.onAppInit(); @@ -56,7 +56,7 @@ public void initialize() { @ReactMethod public void refreshToken() { Log.d(LOGTAG, "Native method invocation: refreshToken()"); - startGcmIntentService(GcmInstanceIdRefreshHandlerService.EXTRA_MANUAL_REFRESH); + startGcmIntentService(FcmInstanceIdRefreshHandlerService.EXTRA_MANUAL_REFRESH); } @ReactMethod @@ -138,7 +138,7 @@ public void onActivityDestroyed(Activity activity) { protected void startGcmIntentService(String extraFlag) { final Context appContext = getReactApplicationContext().getApplicationContext(); - final Intent tokenFetchIntent = new Intent(appContext, GcmInstanceIdRefreshHandlerService.class); + final Intent tokenFetchIntent = new Intent(appContext, FcmInstanceIdRefreshHandlerService.class); tokenFetchIntent.putExtra(extraFlag, true); appContext.startService(tokenFetchIntent); } diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java similarity index 50% rename from android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java rename to android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java index f59665529..cb7763c72 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java @@ -3,16 +3,26 @@ import android.os.Bundle; import android.util.Log; -import com.google.android.gms.gcm.GcmListenerService; +import com.google.firebase.messaging.FirebaseMessagingService; +import com.google.firebase.messaging.RemoteMessage; import com.wix.reactnativenotifications.core.notification.IPushNotification; import com.wix.reactnativenotifications.core.notification.PushNotification; +import java.util.Map; + import static com.wix.reactnativenotifications.Defs.LOGTAG; -public class GcmMessageHandlerService extends GcmListenerService { +/** + * Instance-ID + token refreshing handling service. Contacts the GCM to fetch the updated token. + * + * @author amitd + */ +public class FcmInstanceIdListenerService extends FirebaseMessagingService { @Override - public void onMessageReceived(String s, Bundle bundle) { + public void onMessageReceived(RemoteMessage message){ + Map data = message.getData(); + Bundle bundle = convertMapToBundle(data); Log.d(LOGTAG, "New message from GCM: " + bundle); try { @@ -23,4 +33,14 @@ public void onMessageReceived(String s, Bundle bundle) { Log.v(LOGTAG, "GCM message handling aborted", e); } } + + private Bundle convertMapToBundle(Map map) { + Bundle bundle = new Bundle(); + for (Map.Entry entry : map.entrySet()) { + bundle.putString(entry.getKey(), entry.getValue()); + } + + return bundle; + } + } diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmInstanceIdRefreshHandlerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdRefreshHandlerService.java similarity index 74% rename from android/src/main/java/com/wix/reactnativenotifications/gcm/GcmInstanceIdRefreshHandlerService.java rename to android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdRefreshHandlerService.java index 3aa7aa9dc..8270ad68e 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmInstanceIdRefreshHandlerService.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdRefreshHandlerService.java @@ -3,18 +3,18 @@ import android.app.IntentService; import android.content.Intent; -public class GcmInstanceIdRefreshHandlerService extends IntentService { +public class FcmInstanceIdRefreshHandlerService extends IntentService { public static String EXTRA_IS_APP_INIT = "isAppInit"; public static String EXTRA_MANUAL_REFRESH = "doManualRefresh"; - public GcmInstanceIdRefreshHandlerService() { - super(GcmInstanceIdRefreshHandlerService.class.getSimpleName()); + public FcmInstanceIdRefreshHandlerService() { + super(FcmInstanceIdRefreshHandlerService.class.getSimpleName()); } @Override protected void onHandleIntent(Intent intent) { - IGcmToken gcmToken = GcmToken.get(this); + IFcmToken gcmToken = FcmToken.get(this); if (gcmToken == null) { return; } diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmToken.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java similarity index 51% rename from android/src/main/java/com/wix/reactnativenotifications/gcm/GcmToken.java rename to android/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java index b11a6b5f4..44c8ec6df 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmToken.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java @@ -1,41 +1,38 @@ package com.wix.reactnativenotifications.gcm; import android.content.Context; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.support.annotation.NonNull; import android.util.Log; import com.facebook.react.ReactApplication; import com.facebook.react.ReactInstanceManager; import com.facebook.react.bridge.ReactContext; import com.facebook.react.modules.core.DeviceEventManagerModule; -import com.google.android.gms.gcm.GoogleCloudMessaging; -import com.google.android.gms.iid.InstanceID; +import com.google.android.gms.tasks.OnSuccessListener; +import com.google.firebase.iid.FirebaseInstanceId; +import com.google.firebase.iid.InstanceIdResult; -import static com.wix.reactnativenotifications.Defs.GCM_SENDER_ID_ATTR_NAME; import static com.wix.reactnativenotifications.Defs.LOGTAG; import static com.wix.reactnativenotifications.Defs.TOKEN_RECEIVED_EVENT_NAME; -public class GcmToken implements IGcmToken { +public class FcmToken implements IFcmToken { final protected Context mAppContext; protected static String sToken; - protected GcmToken(Context appContext) { + protected FcmToken(Context appContext) { if (!(appContext instanceof ReactApplication)) { throw new IllegalStateException("Application instance isn't a react-application"); } mAppContext = appContext; } - public static IGcmToken get(Context context) { + public static IFcmToken get(Context context) { Context appContext = context.getApplicationContext(); if (appContext instanceof INotificationsGcmApplication) { - return ((INotificationsGcmApplication) appContext).getGcmToken(context); + return ((INotificationsGcmApplication) appContext).getFcmToken(context); } - return new GcmToken(appContext); + return new FcmToken(appContext); } @Override @@ -73,51 +70,14 @@ public void onAppReady() { } protected void refreshToken() { - try { - sToken = getNewToken(); - } catch (Exception e) { - Log.e(LOGTAG, "Failed to retrieve new token", e); - return; - } - - sendTokenToJS(); - } - - @NonNull - protected String getNewToken() throws Exception { - final InstanceID instanceId = InstanceID.getInstance(mAppContext); - Log.d(LOGTAG, "GCM is refreshing token... instanceId=" + instanceId.getId()); - - // TODO why is this needed? - GoogleCloudMessaging.getInstance(mAppContext).close(); - - try { - final String registrationToken = instanceId.getToken(getSenderId(), GoogleCloudMessaging.INSTANCE_ID_SCOPE); - Log.i(LOGTAG, "GCM has a new token: instanceId=" + instanceId.getId() + ", token=" + registrationToken); - return registrationToken; - } catch (Exception e) { - throw new Exception("FATAL: Failed to fetch a fresh new token, instanceId=" + instanceId.getId(), e); - } - } - - protected String getSenderId() { - final String senderId = getSenderIdFromManifest(); - if (senderId == null) { - throw new IllegalStateException("Sender ID not found in manifest. Did you forget to add it as the value of a '"+GCM_SENDER_ID_ATTR_NAME+"' meta-data field?"); - } - return senderId; - } - - protected String getSenderIdFromManifest() { - final ApplicationInfo appInfo; - try { - appInfo = mAppContext.getPackageManager().getApplicationInfo(mAppContext.getPackageName(), PackageManager.GET_META_DATA); - return appInfo.metaData.getString(GCM_SENDER_ID_ATTR_NAME); - } catch (PackageManager.NameNotFoundException e) { - // Should REALLY never happen cause we're querying for our own package. - Log.e(LOGTAG, "Failed to resolve sender ID from manifest", e); - return null; - } + FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( new OnSuccessListener() { + @Override + public void onSuccess(InstanceIdResult instanceIdResult) { + sToken = instanceIdResult.getToken(); + Log.i(LOGTAG, "FCM has a new token" + "=" + sToken); + sendTokenToJS(); + } + }); } protected void sendTokenToJS() { diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmInstanceIdListenerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmInstanceIdListenerService.java deleted file mode 100644 index 933415f5c..000000000 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmInstanceIdListenerService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.wix.reactnativenotifications.gcm; - -import android.content.Intent; - -import com.google.android.gms.iid.InstanceIDListenerService; - -/** - * Instance-ID + token refreshing handling service. Contacts the GCM to fetch the updated token. - * - * @author amitd - */ -public class GcmInstanceIdListenerService extends InstanceIDListenerService { - - @Override - public void onTokenRefresh() { - // Fetch updated Instance ID token and notify our app's server of any changes (if applicable). - // Google recommends running this from an intent service. - Intent intent = new Intent(this, GcmInstanceIdRefreshHandlerService.class); - startService(intent); - } -} diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/IGcmToken.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/IFcmToken.java similarity index 95% rename from android/src/main/java/com/wix/reactnativenotifications/gcm/IGcmToken.java rename to android/src/main/java/com/wix/reactnativenotifications/gcm/IFcmToken.java index f324a591f..9e75d3901 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/IGcmToken.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/IFcmToken.java @@ -1,6 +1,6 @@ package com.wix.reactnativenotifications.gcm; -public interface IGcmToken { +public interface IFcmToken { /** * Handle an event where we've been notified of a that a fresh token is now available from Google. diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/INotificationsGcmApplication.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/INotificationsGcmApplication.java index 36f59f71c..d318ecc4a 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/INotificationsGcmApplication.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/INotificationsGcmApplication.java @@ -3,5 +3,5 @@ import android.content.Context; public interface INotificationsGcmApplication { - IGcmToken getGcmToken(Context context); + IFcmToken getFcmToken(Context context); } diff --git a/package.json b/package.json index 1f657724d..75bc131d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.1.23", + "version": "1.2.0", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From a67664d0a5a92b5192ed80589613ce556d9721c4 Mon Sep 17 00:00:00 2001 From: Yogev Ben David Date: Wed, 12 Dec 2018 15:37:24 +0200 Subject: [PATCH 69/92] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75bc131d9..f262d189e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0", + "version": "1.2.0-alpha.1", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From a4fd0b664f330d4613da749d645cde5ad12b25c7 Mon Sep 17 00:00:00 2001 From: Joanne Zhu Date: Wed, 9 Jan 2019 13:15:14 -0800 Subject: [PATCH 70/92] Guard against null --- .../reactnativenotifications/gcm/GcmMessageHandlerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java index 9482bb139..8de2dce73 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java @@ -18,7 +18,7 @@ public void onMessageReceived(String s, Bundle bundle) { String rawData = bundle.getString("data"); // Hack by Convoy, all of our data is nested in "data" json. We need to bring it up a level. // we could change this in API but it's backwards incompatible with current app to do so. - if (rawData.length() > 0) { + if (rawData != null && rawData.length() > 0) { try { JSONObject data = new JSONObject(rawData); try { From 18f0d5fba6728216e37154456b77726738271ff2 Mon Sep 17 00:00:00 2001 From: Joanne Zhu Date: Wed, 9 Jan 2019 13:16:10 -0800 Subject: [PATCH 71/92] Bump the version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de30f4253..962a2981d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.1.5-convoyv1", + "version": "1.1.5-convoyv2", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From 8f1e010e5013af7641a06a8f7e7434d1dedce4e4 Mon Sep 17 00:00:00 2001 From: Joanne Zhu Date: Thu, 10 Jan 2019 10:23:56 -0800 Subject: [PATCH 72/92] add fLog --- .../gcm/GcmMessageHandlerService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java index 8de2dce73..dc8f34cc6 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/GcmMessageHandlerService.java @@ -4,6 +4,7 @@ import android.util.Log; import org.json.*; +import com.facebook.common.logging.FLog; import com.google.android.gms.gcm.GcmListenerService; import com.wix.reactnativenotifications.core.notification.IPushNotification; import com.wix.reactnativenotifications.core.notification.PushNotification; @@ -12,13 +13,20 @@ public class GcmMessageHandlerService extends GcmListenerService { + private final static String LOG_TAG = "GcmMessageHandlerService"; + @Override public void onMessageReceived(String s, Bundle bundle) { Log.d(LOGTAG, "New message from GCM: " + bundle); String rawData = bundle.getString("data"); // Hack by Convoy, all of our data is nested in "data" json. We need to bring it up a level. // we could change this in API but it's backwards incompatible with current app to do so. - if (rawData != null && rawData.length() > 0) { + if (rawData == null) { + FLog.i(LOG_TAG, "rawData doesn't contain data key: ", bundle); + return; + } + + if (rawData.length() > 0) { try { JSONObject data = new JSONObject(rawData); try { From ac724477a8d7a3d68e6763c194795a014788137d Mon Sep 17 00:00:00 2001 From: Nathaniel Waggoner Date: Thu, 10 Jan 2019 09:52:43 -0800 Subject: [PATCH 73/92] Fixes two issues when multiple notifications were available while app is backgrounded. 1) When multiple notifications were stacked and one was picked all remaining notifications would be cleared. 2) When multiple notificaitons were stacked and one was clicked, the wrong notification deep link route would be used. This resolves the first by no longer clearing all notifications when one is clicked, and resolves the second by uniquely identifying the pending intents we leverage for our notifications to allow the intent matcher to properly match the correct intent. --- .../core/NotificationIntentAdapter.java | 3 +++ .../core/notification/PushNotification.java | 1 - .../notificationdrawer/PushNotificationsDrawer.java | 12 +++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java b/android/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java index 0413e2f86..8808331b7 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java @@ -13,6 +13,9 @@ public class NotificationIntentAdapter { public static PendingIntent createPendingNotificationIntent(Context appContext, Intent intent, PushNotificationProps notification) { intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle()); + // a unique action, data, type, class, or category must be set, otherwise the intent matcher + // gets confused see https://developer.android.com/reference/android/app/PendingIntent + intent.setAction(String.valueOf(System.currentTimeMillis())); return PendingIntent.getService(appContext, PENDING_INTENT_CODE, intent, PendingIntent.FLAG_ONE_SHOT); } diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index fe82ee1d0..1fd3780d0 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -84,7 +84,6 @@ public void onReceivedLocal(Integer notificationId) throws InvalidNotificationEx @Override public void onOpened() { digestNotification(); - clearAllNotifications(); } @Override diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java b/android/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java index 7b320e16d..acd73c231 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java @@ -32,12 +32,16 @@ protected PushNotificationsDrawer(Context context, AppLaunchHelper appLaunchHelp @Override public void onAppInit() { - clearAll(); + /** + * No OP. + */ } @Override public void onAppVisible() { - clearAll(); + /** + * No OP. + */ } @Override @@ -51,7 +55,9 @@ public void onNewActivity(Activity activity) { @Override public void onNotificationOpened() { - clearAll(); + /** + * No OP. + */ } @Override From 979f45efef108a6d944b655fd422ea40fc831123 Mon Sep 17 00:00:00 2001 From: Nathaniel Waggoner Date: Thu, 10 Jan 2019 13:40:06 -0800 Subject: [PATCH 74/92] Version bump from v2 -> v3. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 962a2981d..dd5098ee3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.1.5-convoyv2", + "version": "1.1.5-convoyv3", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From 6012eefe502ba95920757b1a27e575bdd21d868a Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 24 Jan 2019 13:09:30 -0800 Subject: [PATCH 75/92] Update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1af487a54..90342704a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.1.5-convoyv3", + "version": "1.1.23-convoyv1", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From 79b48d0086cd3947d02b4ff0f0c63e3c73427d78 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 25 Jan 2019 11:40:47 -0800 Subject: [PATCH 76/92] Update gradle --- android/build.gradle | 4 ++-- example/android/myapplication/build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 635fba1da..3ed6e6439 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,7 +5,7 @@ android { buildToolsVersion '28.0.3' defaultConfig { - minSdkVersion 19 + minSdkVersion 16 targetSdkVersion 27 versionCode 1 versionName "1.0" @@ -21,7 +21,7 @@ android { dependencies { // Google's GCM. // compile 'com.google.android.gms:play-services-gcm:15.0.1' - compile "com.google.firebase:firebase-messaging:17.3.0" + compile "com.google.firebase:firebase-messaging:17.3.4" compile 'com.facebook.react:react-native:+' compile 'me.leolin:ShortcutBadger:1.1.8@aar' diff --git a/example/android/myapplication/build.gradle b/example/android/myapplication/build.gradle index 215a039bd..f5fb4798e 100644 --- a/example/android/myapplication/build.gradle +++ b/example/android/myapplication/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "com.wix.reactnativenotifications.app" - minSdkVersion 19 + minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0" From 4dc2b1890be7f8d18e8345ac05f81f115e5a84cb Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 25 Jan 2019 11:41:46 -0800 Subject: [PATCH 77/92] Fix collision of naming --- .../gcm/FcmInstanceIdListenerService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java index d9eb087e4..ea4498bca 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java @@ -25,8 +25,8 @@ public class FcmInstanceIdListenerService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage message){ - Map data = message.getData(); - Bundle bundle = convertMapToBundle(data); + Map messageData = message.getData(); + Bundle bundle = convertMapToBundle(messageData); Log.d(LOGTAG, "New message from GCM: " + bundle); String rawData = bundle.getString("data"); // Hack by Convoy, all of our data is nested in "data" json. We need to bring it up a level. From 162d53d4339f937a20e2cd685b4a0994f0ba55e4 Mon Sep 17 00:00:00 2001 From: Jonathan Stanton Date: Mon, 28 Jan 2019 18:59:25 -0800 Subject: [PATCH 78/92] bump convoy version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a7e9fc297..ec7c617e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0-convoyv1", + "version": "1.2.0-convoyv2", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From dbf19e134a690e24416030d170ee9d64a1a7b0d4 Mon Sep 17 00:00:00 2001 From: Chris Pirich Date: Fri, 15 Feb 2019 14:29:23 -0800 Subject: [PATCH 79/92] fix bundle logging when rawData doesn't have data key --- .../gcm/FcmInstanceIdListenerService.java | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java index ea4498bca..6e6c3d0f2 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java @@ -32,7 +32,7 @@ public void onMessageReceived(RemoteMessage message){ // Hack by Convoy, all of our data is nested in "data" json. We need to bring it up a level. // we could change this in API but it's backwards incompatible with current app to do so. if (rawData == null) { - FLog.i(LOG_TAG, "rawData doesn't contain data key: ", bundle); + FLog.i(LOG_TAG, "rawData doesn't contain data key: " + bundle); return; } diff --git a/package.json b/package.json index ec7c617e4..e54ac5b3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0-convoyv2", + "version": "1.2.0-convoyv3", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From d55bff248489f77444c2036ca9f1133a2c1e8c46 Mon Sep 17 00:00:00 2001 From: Chris Pirich Date: Thu, 28 Feb 2019 13:38:58 -0800 Subject: [PATCH 80/92] add RNNotificationsNativeCallback so native can track PN events that weren't sent to JS --- .../RNNotificationsModule.java | 4 ++-- .../RNNotificationsNativeCallback.java | 7 +++++++ .../RNNotificationsPackage.java | 7 ++++++- .../core/AppLifecycleFacade.java | 2 ++ .../core/JsIOHelper.java | 17 +++++++++-------- .../core/ReactAppLifecycleFacade.java | 10 +++++++++- .../core/notification/PushNotification.java | 6 +++--- .../gcm/FcmInstanceIdListenerService.java | 1 + 8 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 android/src/main/java/com/wix/reactnativenotifications/RNNotificationsNativeCallback.java diff --git a/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java b/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java index f34e2d770..b3a68d6ff 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java +++ b/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java @@ -30,11 +30,11 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements AppLifecycleFacade.AppVisibilityListener, Application.ActivityLifecycleCallbacks { - public RNNotificationsModule(Application application, ReactApplicationContext reactContext) { + public RNNotificationsModule(Application application, RNNotificationsNativeCallback nativeCallback, ReactApplicationContext reactContext) { super(reactContext); if (AppLifecycleFacadeHolder.get() instanceof ReactAppLifecycleFacade) { - ((ReactAppLifecycleFacade) AppLifecycleFacadeHolder.get()).init(reactContext); + ((ReactAppLifecycleFacade) AppLifecycleFacadeHolder.get()).init(reactContext, nativeCallback); } AppLifecycleFacadeHolder.get().addVisibilityListener(this); application.registerActivityLifecycleCallbacks(this); diff --git a/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsNativeCallback.java b/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsNativeCallback.java new file mode 100644 index 000000000..8aabee048 --- /dev/null +++ b/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsNativeCallback.java @@ -0,0 +1,7 @@ +package com.wix.reactnativenotifications; + +import com.facebook.react.bridge.WritableMap; + +public interface RNNotificationsNativeCallback { + void onEventNotSentToJS(String eventName, WritableMap data); +} diff --git a/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java b/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java index 417e12b64..7fd65d2f9 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java +++ b/android/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java @@ -14,14 +14,19 @@ public class RNNotificationsPackage implements ReactPackage { private final Application mApplication; + private RNNotificationsNativeCallback mNativeCallback; public RNNotificationsPackage(Application application) { mApplication = application; } + public void addNativeCallback(RNNotificationsNativeCallback rnNotificationsNativeCallback) { + mNativeCallback = rnNotificationsNativeCallback; + } + @Override public List createNativeModules(ReactApplicationContext reactContext) { - return Arrays.asList(new RNNotificationsModule(mApplication, reactContext)); + return Arrays.asList(new RNNotificationsModule(mApplication, mNativeCallback, reactContext)); } @Override diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/AppLifecycleFacade.java b/android/src/main/java/com/wix/reactnativenotifications/core/AppLifecycleFacade.java index bba1e91ba..508ba6fb9 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/AppLifecycleFacade.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/AppLifecycleFacade.java @@ -1,5 +1,6 @@ package com.wix.reactnativenotifications.core; +import com.wix.reactnativenotifications.RNNotificationsNativeCallback; import com.facebook.react.bridge.ReactContext; public interface AppLifecycleFacade { @@ -11,6 +12,7 @@ interface AppVisibilityListener { boolean isReactInitialized(); ReactContext getRunningReactContext(); + RNNotificationsNativeCallback getNativeCallback(); boolean isAppVisible(); void addVisibilityListener(AppVisibilityListener listener); void removeVisibilityListener(AppVisibilityListener listener); diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/JsIOHelper.java b/android/src/main/java/com/wix/reactnativenotifications/core/JsIOHelper.java index 4d8f4d1d5..cc460af6a 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/JsIOHelper.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/JsIOHelper.java @@ -1,5 +1,6 @@ package com.wix.reactnativenotifications.core; +import com.wix.reactnativenotifications.RNNotificationsNativeCallback; import android.os.Bundle; import com.facebook.react.bridge.Arguments; @@ -8,18 +9,18 @@ import com.facebook.react.modules.core.DeviceEventManagerModule; public class JsIOHelper { - public boolean sendEventToJS(String eventName, Bundle data, ReactContext reactContext) { - if (reactContext != null) { - sendEventToJS(eventName, Arguments.fromBundle(data), reactContext); - return true; - } - return false; + public boolean sendEventToJS(String eventName, Bundle data, AppLifecycleFacade appLifecycleFacade) { + return sendEventToJS(eventName, Arguments.fromBundle(data), appLifecycleFacade); } - public boolean sendEventToJS(String eventName, WritableMap data, ReactContext reactContext) { - if (reactContext != null) { + public boolean sendEventToJS(String eventName, WritableMap data, AppLifecycleFacade appLifecycleFacade) { + RNNotificationsNativeCallback nativeCallback = appLifecycleFacade.getNativeCallback(); + ReactContext reactContext = appLifecycleFacade.getRunningReactContext(); + if (appLifecycleFacade.isReactInitialized() && reactContext != null) { reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data); return true; + } else if (nativeCallback != null) { + nativeCallback.onEventNotSentToJS(eventName, data); } return false; } diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/ReactAppLifecycleFacade.java b/android/src/main/java/com/wix/reactnativenotifications/core/ReactAppLifecycleFacade.java index b185903e6..838c4c19c 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/ReactAppLifecycleFacade.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/ReactAppLifecycleFacade.java @@ -1,5 +1,6 @@ package com.wix.reactnativenotifications.core; +import com.wix.reactnativenotifications.RNNotificationsNativeCallback; import android.util.Log; import com.facebook.react.bridge.LifecycleEventListener; @@ -14,10 +15,12 @@ public class ReactAppLifecycleFacade implements AppLifecycleFacade { private ReactContext mReactContext; private boolean mIsVisible; + private RNNotificationsNativeCallback mNativeCallback; private Set mListeners = new CopyOnWriteArraySet<>(); - public void init(ReactContext reactContext) { + public void init(ReactContext reactContext, RNNotificationsNativeCallback nativeCallback) { mReactContext = reactContext; + mNativeCallback = nativeCallback; reactContext.addLifecycleEventListener(new LifecycleEventListener() { @Override public void onHostResume() { @@ -58,6 +61,11 @@ public ReactContext getRunningReactContext() { return mReactContext; } + @Override + public RNNotificationsNativeCallback getNativeCallback() { + return mNativeCallback; + } + @Override public boolean isAppVisible() { return mIsVisible; diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index 5db4aee09..4e242c6f3 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -307,15 +307,15 @@ protected int createNotificationId(Notification notification) { } private void notifyReceivedToJS() { - mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade.getRunningReactContext()); + mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade); } private void notifiyReceivedForegroundNotificationToJS() { - mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_FOREGROUND_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade.getRunningReactContext()); + mJsIOHelper.sendEventToJS(NOTIFICATION_RECEIVED_FOREGROUND_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade); } private void notifyOpenedToJS() { - mJsIOHelper.sendEventToJS(NOTIFICATION_OPENED_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade.getRunningReactContext()); + mJsIOHelper.sendEventToJS(NOTIFICATION_OPENED_EVENT_NAME, mNotificationProps.asBundle(), mAppLifecycleFacade); } protected void launchOrResumeApp() { diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java index 6e6c3d0f2..2d995c612 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java @@ -98,6 +98,7 @@ public void onMessageReceived(RemoteMessage message){ } catch (IPushNotification.InvalidNotificationException e) { // A GCM message, yes - but not the kind we know how to work with. Log.v(LOGTAG, "GCM message handling aborted", e); + FLog.i(LOG_TAG, "GCM message handling aborted: " + bundle); } } From b554d7e90cd30087dc3ed7ff51c2f49e1b7adbf5 Mon Sep 17 00:00:00 2001 From: Chris Pirich Date: Thu, 28 Feb 2019 13:40:31 -0800 Subject: [PATCH 81/92] bump version to 1.2.0-convoyv4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e54ac5b3f..a2fde3597 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0-convoyv3", + "version": "1.2.0-convoyv4", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From 2f34cf964e87ac8b520b4d2425907dc023d994ff Mon Sep 17 00:00:00 2001 From: Chris Pirich Date: Fri, 1 Mar 2019 09:30:59 -0800 Subject: [PATCH 82/92] treat null rawData like empty rawData - still pass the bundle up for notifications --- .../gcm/FcmInstanceIdListenerService.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java index 2d995c612..1f91d8715 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java @@ -28,15 +28,10 @@ public void onMessageReceived(RemoteMessage message){ Map messageData = message.getData(); Bundle bundle = convertMapToBundle(messageData); Log.d(LOGTAG, "New message from GCM: " + bundle); - String rawData = bundle.getString("data"); // Hack by Convoy, all of our data is nested in "data" json. We need to bring it up a level. // we could change this in API but it's backwards incompatible with current app to do so. - if (rawData == null) { - FLog.i(LOG_TAG, "rawData doesn't contain data key: " + bundle); - return; - } - - if (rawData.length() > 0) { + String rawData = bundle.getString("data"); + if (rawData != null && rawData.length() > 0) { try { JSONObject data = new JSONObject(rawData); try { @@ -90,6 +85,8 @@ public void onMessageReceived(RemoteMessage message){ } catch (JSONException ignored) { Log.d(LOGTAG, "Failed to parse raw data"); } + } else { + FLog.i(LOG_TAG, "rawData doesn't contain data key or data is empty: " + bundle); } try { From 9a7880285b5ea3cc2b8148c7b0d81a490342fb0b Mon Sep 17 00:00:00 2001 From: Jonathan Stanton Date: Tue, 5 Mar 2019 14:21:20 -0800 Subject: [PATCH 83/92] remove references to already declares categories --- RNNotifications/RNNotifications.m | 35 ------------------------------- 1 file changed, 35 deletions(-) diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index 40a544872..864e92fd4 100644 --- a/RNNotifications/RNNotifications.m +++ b/RNNotifications/RNNotifications.m @@ -57,17 +57,6 @@ @implementation RCTConvert (UIUserNotificationActionBehavior) }), UIUserNotificationActionBehaviorDefault, integerValue) @end -@implementation RCTConvert (UIBackgroundFetchResult) - -RCT_ENUM_CONVERTER(UIBackgroundFetchResult, (@{ - @"UIBackgroundFetchResultNewData": @(UIBackgroundFetchResultNewData), - @"UIBackgroundFetchResultNoData": @(UIBackgroundFetchResultNoData), - @"UIBackgroundFetchResultFailed": @(UIBackgroundFetchResultFailed), - }), UIBackgroundFetchResultNoData, integerValue) - -@end - - @implementation RCTConvert (UIMutableUserNotificationAction) + (UIMutableUserNotificationAction *)UIMutableUserNotificationAction:(id)json { @@ -105,30 +94,6 @@ + (UIMutableUserNotificationCategory *)UIMutableUserNotificationCategory:(id)jso } @end -@implementation RCTConvert (UILocalNotification) -+ (UILocalNotification *)UILocalNotification:(id)json -{ - NSDictionary *details = [self NSDictionary:json]; - - UILocalNotification* notification = [UILocalNotification new]; - notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]]; - notification.alertBody = [RCTConvert NSString:details[@"alertBody"]]; - // alertTitle is a property on iOS 8.2 and above: - if ([notification respondsToSelector:@selector(setAlertTitle:)]) { - notification.alertTitle = [RCTConvert NSString:details[@"alertTitle"]]; - } - notification.alertAction = [RCTConvert NSString:details[@"alertAction"]]; - notification.soundName = [RCTConvert NSString:details[@"soundName"]] ?: UILocalNotificationDefaultSoundName; - if ([RCTConvert BOOL:details[@"silent"]]) { - notification.soundName = nil; - } - notification.userInfo = [RCTConvert NSDictionary:details[@"userInfo"]] ?: @{}; - notification.category = [RCTConvert NSString:details[@"category"]]; - - return notification; -} -@end - @implementation RCTConvert (UNNotificationRequest) + (UNNotificationRequest *)UNNotificationRequest:(id)json withId:(NSString*)notificationId { From 640f4003fa33b9287ab5826fb87c866d143b4e23 Mon Sep 17 00:00:00 2001 From: Jonathan Stanton Date: Tue, 5 Mar 2019 14:21:20 -0800 Subject: [PATCH 84/92] remove references to already declares categories --- RNNotifications/RNNotifications.m | 35 ------------------------------- 1 file changed, 35 deletions(-) diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index 40a544872..864e92fd4 100644 --- a/RNNotifications/RNNotifications.m +++ b/RNNotifications/RNNotifications.m @@ -57,17 +57,6 @@ @implementation RCTConvert (UIUserNotificationActionBehavior) }), UIUserNotificationActionBehaviorDefault, integerValue) @end -@implementation RCTConvert (UIBackgroundFetchResult) - -RCT_ENUM_CONVERTER(UIBackgroundFetchResult, (@{ - @"UIBackgroundFetchResultNewData": @(UIBackgroundFetchResultNewData), - @"UIBackgroundFetchResultNoData": @(UIBackgroundFetchResultNoData), - @"UIBackgroundFetchResultFailed": @(UIBackgroundFetchResultFailed), - }), UIBackgroundFetchResultNoData, integerValue) - -@end - - @implementation RCTConvert (UIMutableUserNotificationAction) + (UIMutableUserNotificationAction *)UIMutableUserNotificationAction:(id)json { @@ -105,30 +94,6 @@ + (UIMutableUserNotificationCategory *)UIMutableUserNotificationCategory:(id)jso } @end -@implementation RCTConvert (UILocalNotification) -+ (UILocalNotification *)UILocalNotification:(id)json -{ - NSDictionary *details = [self NSDictionary:json]; - - UILocalNotification* notification = [UILocalNotification new]; - notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]]; - notification.alertBody = [RCTConvert NSString:details[@"alertBody"]]; - // alertTitle is a property on iOS 8.2 and above: - if ([notification respondsToSelector:@selector(setAlertTitle:)]) { - notification.alertTitle = [RCTConvert NSString:details[@"alertTitle"]]; - } - notification.alertAction = [RCTConvert NSString:details[@"alertAction"]]; - notification.soundName = [RCTConvert NSString:details[@"soundName"]] ?: UILocalNotificationDefaultSoundName; - if ([RCTConvert BOOL:details[@"silent"]]) { - notification.soundName = nil; - } - notification.userInfo = [RCTConvert NSDictionary:details[@"userInfo"]] ?: @{}; - notification.category = [RCTConvert NSString:details[@"category"]]; - - return notification; -} -@end - @implementation RCTConvert (UNNotificationRequest) + (UNNotificationRequest *)UNNotificationRequest:(id)json withId:(NSString*)notificationId { From ae42522066d44af4f042d5e84f13cade77425726 Mon Sep 17 00:00:00 2001 From: Jonathan Stanton Date: Tue, 5 Mar 2019 14:21:52 -0800 Subject: [PATCH 85/92] bump convoy version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a2fde3597..a7737001d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0-convoyv4", + "version": "1.2.0-convoyv5", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From c88ea1c3f04339b3c25a08eb2d3e1348d7beae80 Mon Sep 17 00:00:00 2001 From: Jonathan Stanton Date: Tue, 5 Mar 2019 14:43:53 -0800 Subject: [PATCH 86/92] Add headers for UILocalNotification and UIBackgroundFetchResult --- RNNotifications/RNNotifications.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/RNNotifications/RNNotifications.h b/RNNotifications/RNNotifications.h index 25ede8ca1..0936c00bf 100644 --- a/RNNotifications/RNNotifications.h +++ b/RNNotifications/RNNotifications.h @@ -8,6 +8,22 @@ #import #endif +#if __has_include() +#import +#elif __has_include("React/RCTConvert.h") +#import "React/RCTConvert.h" +#else +#import "RCTConvert.h" +#endif + +@interface RCTConvert (UILocalNotification) ++ (UILocalNotification *)UILocalNotification:(id)json; +@end + +@interface RCTConvert (UIBackgroundFetchResult) ++(UIBackgroundFetchResult *)UIBackgroundFetchResult:(id)json; +@end + @interface RNNotifications : NSObject typedef void (^RCTRemoteNotificationCallback)(UIBackgroundFetchResult result); From 3455ca88fde2f23db15a06b6ae07b3d2032c5705 Mon Sep 17 00:00:00 2001 From: Nathaniel Waggoner Date: Wed, 6 Mar 2019 15:07:01 -0800 Subject: [PATCH 87/92] Bump gradle build tools and move to implementation and api keywords to resolve build warnings --- android/build.gradle | 29 +++++++++++++++++++++-------- package.json | 2 +- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 3ed6e6439..95ca5cdb9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,8 +1,22 @@ +buildscript { + repositories { + maven { + url "https://maven.google.com" + } + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.0.1' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + apply plugin: 'com.android.library' android { compileSdkVersion 27 - buildToolsVersion '28.0.3' defaultConfig { minSdkVersion 16 @@ -20,13 +34,12 @@ android { dependencies { // Google's GCM. -// compile 'com.google.android.gms:play-services-gcm:15.0.1' - compile "com.google.firebase:firebase-messaging:17.3.4" - compile 'com.facebook.react:react-native:+' + api "com.google.firebase:firebase-messaging:17.3.4" + implementation 'com.facebook.react:react-native:+' - compile 'me.leolin:ShortcutBadger:1.1.8@aar' + implementation 'me.leolin:ShortcutBadger:1.1.8@aar' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:2.+' - testCompile 'org.robolectric:robolectric:3.1.4' + testImplementation 'junit:junit:4.12' + testImplementation 'org.mockito:mockito-core:2.+' + testImplementation 'org.robolectric:robolectric:3.1.4' } diff --git a/package.json b/package.json index a7737001d..9eecb59a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0-convoyv5", + "version": "1.2.0-convoyv6", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From 4bbd6aff862b3dd6606085a50c551c0aa638eb6a Mon Sep 17 00:00:00 2001 From: Jonathan Stanton Date: Tue, 16 Jul 2019 13:46:34 -0700 Subject: [PATCH 88/92] Say when! -- For notifications N and above we need to set a "when" time --- .../core/notification/PushNotification.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index 4e242c6f3..3cd03dc30 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -211,6 +211,7 @@ protected Notification.Builder getNotificationBuilder(PendingIntent intent) { .setContentIntent(intent) .setVibrate(mNotificationProps.getVibrationPattern()) .setSmallIcon(smallIconResId) + .setShowWhen(true) .setAutoCancel(true); int badge = mNotificationProps.getBadge(); From 125406ae4780be9a5e813e8411e77c7e8e521802 Mon Sep 17 00:00:00 2001 From: Jonathan Stanton Date: Tue, 16 Jul 2019 14:09:31 -0700 Subject: [PATCH 89/92] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9eecb59a5..81dc37469 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0-convoyv6", + "version": "1.2.0-convoyv7", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From 718317cf0ee4cae8ceeea8ded3cdec0d81e7d816 Mon Sep 17 00:00:00 2001 From: NathanielWaggoner Date: Fri, 19 Jul 2019 13:15:55 -0700 Subject: [PATCH 90/92] Updates the FcmToken method sendTokenToJS to always post a runnable to the UI thread. This is required due to the changes around JobIntentService required for scheduling work on android O and above. In this mode the FcmToken methods can be executed on threads other than the UI thread. This flow can cause the main ReactNativeInstance to be null, and thus require a creation call to execute. Because this call must be executed on a main thread we get crashes. Solution is to always post this action to the main thread as a protection against background execution of the ReactNativeInstance.createReactNativeInstanceManager call. . --- .../gcm/FcmToken.java | 32 +++++++++++++++---- package.json | 2 +- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java index 44c8ec6df..6b8a04fec 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java +++ b/android/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java @@ -1,6 +1,8 @@ package com.wix.reactnativenotifications.gcm; import android.content.Context; +import android.os.Handler; +import android.os.Looper; import android.util.Log; import com.facebook.react.ReactApplication; @@ -20,6 +22,22 @@ public class FcmToken implements IFcmToken { protected static String sToken; + private final Runnable sendTokenToJsRunnable = new Runnable() { + @Override + public void run() { + synchronized (mAppContext) { + final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager(); + final ReactContext reactContext = instanceManager.getCurrentReactContext(); + // Note: Cannot assume react-context exists cause this is an async dispatched service. + if (reactContext != null && reactContext.hasActiveCatalystInstance()) { + reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(TOKEN_RECEIVED_EVENT_NAME, sToken); + } + } + } + }; + + private final Handler mainThreadHandler = new Handler(Looper.getMainLooper()); + protected FcmToken(Context appContext) { if (!(appContext instanceof ReactApplication)) { throw new IllegalStateException("Application instance isn't a react-application"); @@ -80,13 +98,13 @@ public void onSuccess(InstanceIdResult instanceIdResult) { }); } + /** + * This method can be called from a background thread. The call to getReactInstanceManager() + * can end up calling createReactInstanceManager() which must be called from the UI thread. + * + * Because of this restriction we make a point to always post this runnable to a main thread. + */ protected void sendTokenToJS() { - final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager(); - final ReactContext reactContext = instanceManager.getCurrentReactContext(); - - // Note: Cannot assume react-context exists cause this is an async dispatched service. - if (reactContext != null && reactContext.hasActiveCatalystInstance()) { - reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(TOKEN_RECEIVED_EVENT_NAME, sToken); - } + mainThreadHandler.post(sendTokenToJsRunnable); } } diff --git a/package.json b/package.json index 81dc37469..d49ec15b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0-convoyv7", + "version": "1.2.0-convoyv8", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT", From 8fa421327bed000ee94a79d4561ff8a73abd9a82 Mon Sep 17 00:00:00 2001 From: Greg Foltz Date: Fri, 30 Aug 2019 10:16:56 -0700 Subject: [PATCH 91/92] Use BigText style for Android push notifiactions --- .../core/notification/PushNotification.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index 3cd03dc30..0f136715f 100644 --- a/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -207,6 +207,8 @@ protected Notification.Builder getNotificationBuilder(PendingIntent intent) { notificationBuilder.setContentTitle(title) .setContentText(mNotificationProps.getBody()) + .setStyle(new Notification.BigTextStyle() + .bigText(mNotificationProps.getBody())) .setPriority(mNotificationProps.getPriority()) .setContentIntent(intent) .setVibrate(mNotificationProps.getVibrationPattern()) From c01d8da156f94c8149116f61f45054eb8de7c5f1 Mon Sep 17 00:00:00 2001 From: Greg Foltz Date: Thu, 5 Sep 2019 10:43:40 -0700 Subject: [PATCH 92/92] Bump package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d49ec15b5..afea6384e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-notifications", - "version": "1.2.0-convoyv8", + "version": "1.2.0-convoyv9", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", "author": "Lidan Hifi ", "license": "MIT",