@@ -109,6 +109,15 @@ 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+ if ([userInfo valueForKeyPath:@"aps.badge"] != nil) {
116+ [UIApplication sharedApplication].applicationIconBadgeNumber=[[[userInfo objectForKey:@"aps"] objectForKey:@"badge"] intValue];
117+ }
118+ completionHandler(UIBackgroundFetchResultNewData);
119+}
120+
112121- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
113122 // Sent to the delegate when Apple Push Notification service cannot successfully complete the registration process.
114123 NSString *errorString = [error localizedDescription];