Skip to content

Commit ec7dcc0

Browse files
authored
Merge pull request #46 from CatalystCode/registration-id
Retrieve notification hub registration id after registering successfully
2 parents 61e100e + 22c332b commit ec7dcc0

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)