Skip to content

Commit f4508d6

Browse files
authored
Merge pull request #67 from CatalystCode/thcao/fix-notification
Fixing notification not received issue
2 parents 204324a + 47ab521 commit f4508d6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ android {
2323
dependencies {
2424
implementation fileTree(dir: 'libs', include: ['*.jar'])
2525
implementation 'com.facebook.react:react-native:+'
26+
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
2627
implementation 'com.google.firebase:firebase-messaging:17.6.0'
2728
implementation 'com.android.support:appcompat-v7:28.0.0'
2829
implementation 'com.microsoft.azure:notification-hubs-android-sdk:0.4@aar'

android/src/main/java/com/azure/reactnative/notificationhub/ReactNativeNotificationHubModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.facebook.react.bridge.ReadableArray;
2424
import com.facebook.react.bridge.ReadableMap;
2525
import com.facebook.react.bridge.UiThreadUtil;
26+
import com.microsoft.windowsazure.notifications.NotificationsManager;
2627

2728
public class ReactNativeNotificationHubModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
2829
public static final String NOTIF_REGISTER_AZURE_HUB_EVENT = "azureNotificationHubRegistered";
@@ -105,6 +106,7 @@ public void register(ReadableMap config, Promise promise) {
105106

106107
Intent intent = new Intent(reactContext, ReactNativeRegistrationIntentService.class);
107108
reactContext.startService(intent);
109+
NotificationsManager.handleNotifications(reactContext, senderID, ReactNativeNotificationsHandler.class);
108110
}
109111

110112
@ReactMethod
@@ -124,6 +126,7 @@ public void unregister(Promise promise) {
124126
try {
125127
hub.unregister();
126128
notificationHubUtil.setRegistrationID(reactContext, null);
129+
NotificationsManager.stopHandlingNotifications(reactContext);
127130
} catch (Exception e) {
128131
promise.reject(ERROR_NOTIFICATION_HUB, e);
129132
}

0 commit comments

Comments
 (0)