diff --git a/contrib/mobile/iOS/Onelab/AppDelegate.mm b/contrib/mobile/iOS/Onelab/AppDelegate.mm index f4dc901f95e680d309dd7bb2f5404fd1c8b4f285..863f1df045e0f99f0339904e29a9a64a34cf0cf8 100644 --- a/contrib/mobile/iOS/Onelab/AppDelegate.mm +++ b/contrib/mobile/iOS/Onelab/AppDelegate.mm @@ -50,4 +50,10 @@ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } +-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification +{ + application.applicationIconBadgeNumber = -1; + [UIApplication sharedApplication].applicationIconBadgeNumber = -1; +} + @end diff --git a/contrib/mobile/iOS/Onelab/ModelViewController.mm b/contrib/mobile/iOS/Onelab/ModelViewController.mm index c3cd92fa04a4b7ebd6c1885cbd5820a6fb289a73..8d0c5d5e465330cb8cc12457fc3d8fde1eb1a3bb 100644 --- a/contrib/mobile/iOS/Onelab/ModelViewController.mm +++ b/contrib/mobile/iOS/Onelab/ModelViewController.mm @@ -140,9 +140,10 @@ onelab_cb("compute"); appDelegate->compute = NO; UILocalNotification *localNotif = [[UILocalNotification alloc] init]; - if (localNotif) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground && localNotif) { localNotif.alertBody = @"Computation finished"; localNotif.alertAction = @"View"; + localNotif.hasAction = true; localNotif.soundName = UILocalNotificationDefaultSoundName; localNotif.applicationIconBadgeNumber = 1; [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; @@ -152,6 +153,7 @@ }); dispatch_group_notify(group, dispatch_get_main_queue(), ^{ + [UIApplication sharedApplication].applicationIconBadgeNumber = -1; [_runStopButton setAction:@selector(compute)]; [_runStopButton setTitle:@"Run"]; [_progressLabel setHidden:YES];