Skip to content

Commit

Permalink
[feature][SDK-199] 'getUserId' method added
Browse files Browse the repository at this point in the history
  • Loading branch information
akidison committed Feb 12, 2024
1 parent 1a9176d commit 91e76ea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ class PushNotification {
PushwooshModule.getHwid(success);
}

//Function: getUserId
//Call this to get Pushwoosh User ID used for communications with Pushwoosh API
//
//Example:
//(start code)
// Pushwoosh.getUserId();
//(end)
getUserId(success: Function) {
PushwooshModule.getUserId(success);
}

//Function: setUserId
//[android, ios] Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
//This allows data and events to be matched across multiple user devices.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ public void getHwid(Callback callback) {
callback.invoke(Pushwoosh.getInstance().getHwid());
}

@ReactMethod
public void getUserId(Callback callback) {
callback.invoke(Pushwoosh.getInstance().getUserId());
}

@ReactMethod
public void setUserId(String userId) {
PushwooshInApp.getInstance().setUserId(userId);
Expand Down
6 changes: 6 additions & 0 deletions src/ios/PushwooshPlugin/Pushwoosh.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ - (dispatch_queue_t)methodQueue {
}
}

RCT_EXPORT_METHOD(getUserId:(RCTResponseSenderBlock)callback) {
if (callback) {
callback(@[ [[Pushwoosh sharedInstance] getUserId] ]);
}
}

RCT_EXPORT_METHOD(getPushToken:(RCTResponseSenderBlock)callback) {
if (callback) {
callback(@[ objectOrNull([[PushNotificationManager pushManager] getPushToken]) ]);
Expand Down

0 comments on commit 91e76ea

Please sign in to comment.