Skip to content

Commit 375616a

Browse files
committed
Make jwt token optional
1 parent 67942c3 commit 375616a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ios/RCTOneSignal/RCTOneSignalEventEmitter.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body {
106106
}
107107

108108
RCT_EXPORT_METHOD(login:(NSString *)externalId jwtToken:(NSString *)jwtToken) {
109+
// Pass nil if jwtToken is not provided
110+
if (jwtToken == (id)[NSNull null]) {
111+
jwtToken = nil;
112+
}
113+
109114
[OneSignal login:externalId withToken:jwtToken];
110115
}
111116

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ export namespace OneSignal {
104104
* If your integration is user-centric, or you want the ability to identify the user beyond the current device, the
105105
* login method should be called to identify the user.
106106
*/
107-
export function login(externalId: string, jwtToken: string) {
107+
export function login(externalId: string, jwtToken?: string) {
108108
if (!isNativeModuleLoaded(RNOneSignal)) return;
109109

110-
RNOneSignal.login(externalId, jwtToken);
110+
RNOneSignal.login(externalId, jwtToken || null);
111111
}
112112

113113
/**

0 commit comments

Comments
 (0)