on master help sign in
Allow remote badge updates while app is in foreground
commitbbc6b2449fb69a15f883d656f1b1051d2382ef94 authorSam Tay <sam.chong.tay@gmail.com> dateMon 12 Feb 2018, 19:47 (9 years ago) parent037884f
1 file changed+7
jsaddle-wkwebview/cbits-uikit/AppDelegate.m+7
jsaddle-wkwebview/cbits-uikit/AppDelegate.m+7
@@ -109,6 +109,13 @@ HsStablePtr global_didFailToRegisterForRemoteNotificationsWithError = 0;
109109 callWithCString([deviceTokenString UTF8String], global_didRegisterForRemoteNotificationsWithDeviceToken);
110110}
111111
112+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
113+ // Sent when the application receives remote notifications in the foreground or background
114+ // TODO Allow a configurable CString -> IO () to be passed into AppDelegateConfig
115+ [UIApplication sharedApplication].applicationIconBadgeNumber=[[[userInfo objectForKey:@"aps"] valueForKey:@"badge"] intValue];
116+ completionHandler(UIBackgroundFetchResultNewData);
117+}
118+
112119- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
113120 // Sent to the delegate when Apple Push Notification service cannot successfully complete the registration process.
114121 NSString *errorString = [error localizedDescription];