Skip to content

Commit

Permalink
Make jwt token optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jennantilla committed Nov 21, 2024
1 parent 67942c3 commit 375616a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ios/RCTOneSignal/RCTOneSignalEventEmitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body {
}

RCT_EXPORT_METHOD(login:(NSString *)externalId jwtToken:(NSString *)jwtToken) {
// Pass nil if jwtToken is not provided
if (jwtToken == (id)[NSNull null]) {
jwtToken = nil;
}

[OneSignal login:externalId withToken:jwtToken];
}

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ export namespace OneSignal {
* If your integration is user-centric, or you want the ability to identify the user beyond the current device, the
* login method should be called to identify the user.
*/
export function login(externalId: string, jwtToken: string) {
export function login(externalId: string, jwtToken?: string) {
if (!isNativeModuleLoaded(RNOneSignal)) return;

RNOneSignal.login(externalId, jwtToken);
RNOneSignal.login(externalId, jwtToken || null);
}

/**
Expand Down

0 comments on commit 375616a

Please sign in to comment.