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 4c04a09 commit 4a6ac89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/ios/OneSignalPush.m
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ - (void)setAlertLevel:(CDVInvokedUrlCommand*)command {
}

- (void)login:(CDVInvokedUrlCommand*)command {
[OneSignal login:command.arguments[0] withToken:command.arguments[1]];
NSString *externalId = command.arguments[0];
NSString *jwtToken = command.arguments.count > 1 ? command.arguments[1] : nil;

[OneSignal login:externalId withToken:jwtToken];
}

- (void)logout:(CDVInvokedUrlCommand*)command {
Expand Down
7 changes: 4 additions & 3 deletions www/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ export class OneSignalPlugin {
/**
* Log in to OneSignal under the user identified by the [externalId] provided. The act of logging a user into the OneSignal SDK will switch the [user] context to that specific user.
* @param {string} externalId
* @param {string} jwtToken
* @param {string} jwtToken - Optional
* @returns void
*/
login(externalId: string, jwtToken: string): void {
window.cordova.exec(function () { }, function () { }, "OneSignalPush", "login", [externalId, jwtToken]);
login(externalId: string, jwtToken?: string): void {
const args = jwtToken ? [externalId, jwtToken] : [externalId];
window.cordova.exec(function () { }, function () { }, "OneSignalPush", "login", args);
}

/**
Expand Down

0 comments on commit 4a6ac89

Please sign in to comment.