Skip to content

Commit

Permalink
Handle when jwt_required is not returned
Browse files Browse the repository at this point in the history
  • Loading branch information
nan-li committed Oct 5, 2024
1 parent 1fbddcf commit 57c6f08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,20 @@ extension OneSignalUserManagerImpl {
jwtConfig.isRequired = required
}

/**
This is called when remote params does not return the property `IOS_JWT_REQUIRED`.
It is likely this feature is not enabled for the app, so we will assume it is off.
However, don't overwrite the value if this has already been set.
*/
@objc
public func remoteParamsReturnedUnknownRequiresUserAuth() {
guard jwtConfig.isRequired == nil else {
return
}
OneSignalLog.onesignalLog(.LL_DEBUG, message: "remoteParamsReturnedUnknownRequiresUserAuth called")
jwtConfig.isRequired = false
}

@objc
public func subscribeToJwtConfig(_ listener: OSUserJwtConfigListener, key: String) {
jwtConfig.subscribe(listener, key: key)
Expand Down
3 changes: 3 additions & 0 deletions iOS_SDK/OneSignalSDK/Source/OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,9 @@ + (void)downloadIOSParamsWithAppId:(NSString *)appId {
[OneSignalCoreImpl.sharedClient executeRequest:[OSRequestGetIosParams withUserId:userId appId:appId] onSuccess:^(NSDictionary *result) {
if (result[IOS_JWT_REQUIRED]) {
OneSignalUserManagerImpl.sharedInstance.requiresUserAuth = [result[IOS_JWT_REQUIRED] boolValue];
} else {
// Remote params did not return IOS_JWT_REQUIRED
[OneSignalUserManagerImpl.sharedInstance remoteParamsReturnedUnknownRequiresUserAuth];
}

if (result[IOS_USES_PROVISIONAL_AUTHORIZATION] != (id)[NSNull null]) {
Expand Down

0 comments on commit 57c6f08

Please sign in to comment.