Skip to content

Commit 6ffcefc

Browse files
committed
Add OneSignal.Notifications.permissionNative
* Add permissionNative which tells if it's provisional, ephemeral, denied, authorized etc * Expose enum OSNotificationPermission which has 5 values
1 parent 447b1c5 commit 6ffcefc

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ typedef void (^OSNotificationWillShowInForegroundBlock)(OSNotification * _Nonnul
3636
typedef void (^OSNotificationOpenedBlock)(OSNotificationOpenedResult * _Nonnull result);
3737

3838
/**
39-
Public API.
39+
Public API for the Notifications namespace.
4040
*/
4141
@protocol OSNotifications <NSObject>
4242
+ (BOOL)permission NS_REFINED_FOR_SWIFT;
4343
+ (BOOL)canRequestPermission NS_REFINED_FOR_SWIFT;
44+
+ (OSNotificationPermission)permissionNative NS_REFINED_FOR_SWIFT;
4445
+ (void)setNotificationWillShowInForegroundHandler:(OSNotificationWillShowInForegroundBlock _Nullable)block;
4546
+ (void)setNotificationOpenedHandler:(OSNotificationOpenedBlock _Nullable)block;
4647
+ (void)requestPermission:(OSUserResponseBlock _Nullable )block;

iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ + (BOOL)canRequestPermission {
232232
return !self.currentPermissionState.answeredPrompt;
233233
}
234234

235+
+ (OSNotificationPermission)permissionNative {
236+
return self.currentPermissionState.status;
237+
}
238+
235239
+ (void)requestPermission:(OSUserResponseBlock)block {
236240
// return if the user has not granted privacy permissions
237241
if ([OSPrivacyConsentController shouldLogMissingPrivacyConsentErrorWithMethodName:@"requestPermission:"])

iOS_SDK/OneSignalSDK/Source/OneSignalSwiftInterface.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public extension OSNotifications {
9393
return __canRequestPermission()
9494
}
9595

96+
static var permissionNative: OSNotificationPermission {
97+
return __permissionNative()
98+
}
99+
96100
static func registerForProvisionalAuthorization(_ block: OSUserResponseBlock?) {
97101
return __register(forProvisionalAuthorization: block)
98102
}

0 commit comments

Comments
 (0)