Skip to content

Commit 22c332b

Browse files
committed
Supported getting notification hub registration ID for Android.
1 parent 61e100e commit 22c332b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ public void unregister(Promise promise) {
110110
promise.reject(ERROR_NOTIFICATION_HUB, e);
111111
}
112112
}
113+
114+
@ReactMethod
115+
public void getRegistrationId(Promise promise) {
116+
NotificationHubUtil notificationHubUtil = NotificationHubUtil.getInstance();
117+
ReactContext reactContext = getReactApplicationContext();
118+
String registrationId = notificationHubUtil.getRegistrationID(reactContext);
119+
120+
if (registrationId == null) {
121+
promise.reject(ERROR_NOT_REGISTERED, "No registration to Azure Notification Hub.");
122+
}
123+
else {
124+
promise.resolve(registrationId);
125+
}
126+
}
113127

114128
private static class GoogleApiAvailabilityRunnable implements Runnable {
115129
private final Activity activity;

0 commit comments

Comments
 (0)