iOS Question Notification allowed

MESTERM

Member
Licensed User
Hi is there a way to check if the user has enabled notifications or not and if not to be taken to the setting page to enable notification or to have another pop up.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code (iOS 10+):
B4X:
Dim no As NativeObject = Me
no.RunMethod("NotificationStatus", Null)
Wait For Authorization_Status(status As Int)
'0 - not determined
'1 - denied
'2 - authroized
'3 - provisional (authorized)
Log(status)


#if OBJC
#import <UserNotifications/UserNotifications.h>
- (void) NotificationStatus {
   [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler: ^(UNNotificationSettings* settings) {
        [self.bi raiseUIEvent:nil event:@"authorization_status:" params:@[@(settings.authorizationStatus)]];
   }];
  
}
#End If
Settings page: https://www.b4x.com/android/forum/threads/open-default-settings-app.51115/#post-319865
 
Upvote 0
Top