@@ -50,12 +50,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5050// [FIRApp configure];
5151
5252 NSLog (@" Bundle URL: %@ " , [[NSBundle mainBundle ] bundleURL ]);
53-
5453 [OneSignal.Debug setLogLevel: ONE_S_LL_VERBOSE];
5554 [OneSignal.Debug setVisualLevel: ONE_S_LL_NONE];
55+
56+ [OneSignal initialize: [AppDelegate getOneSignalAppId ] withLaunchOptions: launchOptions];
57+
5658 _notificationDelegate = [OneSignalNotificationCenterDelegate new ];
5759
5860 id openNotificationHandler = ^(OSNotificationOpenedResult *result) {
61+ // TODO: opened handler Not triggered
5962 NSLog (@" OSNotificationOpenedResult: %@ " , result.action );
6063 #pragma clang diagnostic push
6164 #pragma clang diagnostic ignored "-Wdeprecated"
@@ -80,7 +83,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
8083 // OneSignal Init with app id and lauch options
8184 [OneSignal setLaunchURLsInApp: YES ];
8285 [OneSignal setProvidesNotificationSettingsView: NO ];
83- [OneSignal initialize: [AppDelegate getOneSignalAppId ] withLaunchOptions: launchOptions];
86+
8487
8588 [OneSignal.Notifications requestPermission: ^(BOOL accepted) {
8689 NSLog (@" OneSignal Demo App requestPermission: %d " , accepted);
@@ -92,13 +95,18 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
9295 [OneSignal.Notifications setNotificationWillShowInForegroundHandler: notificationReceiverBlock];
9396 [OneSignal.Notifications setNotificationOpenedHandler: openNotificationHandler];
9497
98+ OSPushSubscriptionState* state = [OneSignal.User.pushSubscription addObserver: self ];
99+ NSLog (@" OneSignal Demo App push subscription observer added, current state: %@ " , state);
100+
101+ [OneSignal.Notifications addPermissionObserver: self ];
102+
95103 NSLog (@" UNUserNotificationCenter.delegate: %@ " , UNUserNotificationCenter .currentNotificationCenter .delegate );
96104
97105 return YES ;
98106}
99107
100- #define ONESIGNAL_APP_ID_DEFAULT @" 0ba9731b-33bd-43f4-8b59-61172e27447d "
101- #define ONESIGNAL_APP_ID_KEY_FOR_TESTING @" ONESIGNAL_APP_ID_KEY_FOR_TESTING "
108+ #define ONESIGNAL_APP_ID_DEFAULT @" 1688d8f2-da7f-4815-8ee3-9d13788482c8 "
109+ #define ONESIGNAL_APP_ID_KEY_FOR_TESTING @" 1688d8f2-da7f-4815-8ee3-9d13788482c8 "
102110
103111+ (NSString *)getOneSignalAppId {
104112 NSString * userDefinedAppId = [[NSUserDefaults standardUserDefaults ] objectForKey: ONESIGNAL_APP_ID_KEY_FOR_TESTING];
@@ -118,10 +126,10 @@ - (void) onOSPermissionChanged:(OSPermissionStateChanges*)stateChanges {
118126 NSLog (@" onOSPermissionChanged: %@ " , stateChanges);
119127}
120128
121- - (void ) onOSSubscriptionChanged : (OSSubscriptionStateChanges *)stateChanges {
122- NSLog (@" onOSSubscriptionChanged : %@ " , stateChanges);
129+ - (void )onOSPushSubscriptionChangedWithStateChanges : (OSPushSubscriptionStateChanges *)stateChanges {
130+ NSLog (@" onOSPushSubscriptionChangedWithStateChanges : %@ " , stateChanges);
123131 ViewController* mainController = (ViewController*) self.window .rootViewController ;
124- mainController.subscriptionSegmentedControl .selectedSegmentIndex = (NSInteger ) stateChanges.to .isSubscribed ;
132+ mainController.subscriptionSegmentedControl .selectedSegmentIndex = (NSInteger ) stateChanges.to .optedIn ;
125133}
126134
127135#pragma mark OSInAppMessageDelegate
0 commit comments