@@ -9,8 +9,9 @@ extern void handlerCString(const char * _Nonnull, HsStablePtr);
11HsStablePtr globalHandler = 0;
11HsStablePtr globalHandler = 0;
12−HsStablePtr global_didRegisterForRemoteNotificationsWithDeviceToken = 0;
12+BOOL global_requestAuthorizationWithOptions = NO;
13BOOL global_registerForRemoteNotifications = NO;
13BOOL global_registerForRemoteNotifications = NO;
14+HsStablePtr global_didRegisterForRemoteNotificationsWithDeviceToken = 0;
15@implementation AppDelegate
16@implementation AppDelegate
@@ -21,11 +22,13 @@ BOOL global_registerForRemoteNotifications = NO;
21 self.window.backgroundColor = [UIColor whiteColor];
22 self.window.backgroundColor = [UIColor whiteColor];
22 [self.window makeKeyAndVisible];
23 [self.window makeKeyAndVisible];
23 UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
24 UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
25+ if (global_requestAuthorizationWithOptions) {
24− [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound + UNAuthorizationOptionBadge)
26+ [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound + UNAuthorizationOptionBadge)
25− completionHandler:^(BOOL granted, NSError * _Nullable error) {
27+ completionHandler:^(BOOL granted, NSError * _Nullable error) {
26− // Handler used to alter application behavior based on types of notifications authorized
28+ // Handler used to alter application behavior based on types of notifications authorized
27− // Perhaps we don't need to do anything here.
29+ // Perhaps we don't need to do anything here.
29 if (global_registerForRemoteNotifications) {
32 if (global_registerForRemoteNotifications) {
30 [application registerForRemoteNotifications];
33 [application registerForRemoteNotifications];
@@ -71,12 +74,14 @@ BOOL global_registerForRemoteNotifications = NO;
72void runInWKWebView(HsStablePtr handler,
75void runInWKWebView(HsStablePtr handler,
73 const char * _Nonnull progName,
76 const char * _Nonnull progName,
77+ const BOOL hs_requestAuthorizationWithOptions,
74 const BOOL hs_registerForRemoteNotifications,
78 const BOOL hs_registerForRemoteNotifications,
75 HsStablePtr hs_didRegisterForRemoteNotificationsWithDeviceToken) {
79 HsStablePtr hs_didRegisterForRemoteNotificationsWithDeviceToken) {
76 @autoreleasepool {
80 @autoreleasepool {
77 globalHandler = handler;
81 globalHandler = handler;
78− global_didRegisterForRemoteNotificationsWithDeviceToken = hs_didRegisterForRemoteNotificationsWithDeviceToken;
82+ global_requestAuthorizationWithOptions = hs_requestAuthorizationWithOptions;
79 global_registerForRemoteNotifications = hs_registerForRemoteNotifications;
83 global_registerForRemoteNotifications = hs_registerForRemoteNotifications;
84+ global_didRegisterForRemoteNotificationsWithDeviceToken = hs_didRegisterForRemoteNotificationsWithDeviceToken;
80 const char * _Nonnull argv [] = {"", 0};
85 const char * _Nonnull argv [] = {"", 0};
81 UIApplicationMain(0, argv, nil, NSStringFromClass([AppDelegate class]));
86 UIApplicationMain(0, argv, nil, NSStringFromClass([AppDelegate class]));