Skip to content

Commit

Permalink
Add iOS implementation
Browse files Browse the repository at this point in the history
- new methods updateUserJwt and addUserJwtInvalidatedListener added to the bridge
  • Loading branch information
jennantilla committed Nov 14, 2024
1 parent 9cd7257 commit 266bf60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ios/OneSignalPush.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

- (void)login:(CDVInvokedUrlCommand* _Nonnull)command;
- (void)logout:(CDVInvokedUrlCommand* _Nonnull)command;
- (void)updateUserJwt:(CDVInvokedUrlCommand* _Nonnull)command;
- (void)addUserJwtInvalidatedListener:(CDVInvokedUrlCommand* _Nonnull)command;

- (void)addTags:(CDVInvokedUrlCommand* _Nonnull)command;
- (void)removeTags:(CDVInvokedUrlCommand* _Nonnull)command;
Expand Down
15 changes: 14 additions & 1 deletion src/ios/OneSignalPush.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
NSString* inAppMessageDidDismissCallbackId;
NSString* inAppMessageClickedCallbackId;
NSString* userObserverCallbackId;
NSString* addUserJwtInvalidatedListenerCallbackId;

OSNotificationClickEvent *actionNotification;
OSNotification *notification;
Expand Down Expand Up @@ -367,13 +368,25 @@ - (void)setAlertLevel:(CDVInvokedUrlCommand*)command {
}

- (void)login:(CDVInvokedUrlCommand*)command {
[OneSignal login:command.arguments[0]];
[OneSignal login:command.arguments[0] withToken:command.arguments[1]];
}

- (void)logout:(CDVInvokedUrlCommand*)command {
[OneSignal logout];
}

- (void)updateUserJwt:(CDVInvokedUrlCommand*)command {
[OneSignal updateUserJwt:command.arguments[0] withToken:command.arguments[1]];
}

- (void)addUserJwtInvalidatedListener:(CDVInvokedUrlCommand*)command {
bool first = addUserJwtInvalidatedListenerCallbackId == nil;
addUserJwtInvalidatedListenerCallbackId = command.callbackId;
if (first) {
[OneSignal addUserJwtInvalidatedListener:self];
}
}

- (void)addTags:(CDVInvokedUrlCommand*)command {
[OneSignal.User addTags:command.arguments[0]];
}
Expand Down

0 comments on commit 266bf60

Please sign in to comment.