Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm adding a video chat to my app and use PushKit to get a pushNotification when the app is in the background. I Can't use the CallKit for video as it mess up the SDK I'm using so I have added a local push notification that fire up from the PushKit delegate method.

I'm wondering how Whatsapp does it with their Video call. For now they are showing a push notification but in a way that I can't recognize. The push is fired up with two vibrations and after two seconds there is a new push that overlaps the first notification and you can feel another two vibrations and so on until you answer. How do they do it as you can't add vibration over and over again and how do they delete the notification and establish a new one in the background as the NSTimer is not working in the background. If I add [[UIApplication sharedApplication] beginBackgroundTaskWithName:expirationHandler:] then I can use the timer for 180 seconds but only if the app was active.

So the real problem is how to add a local notification that can repeat itself few times and also add vibration to it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
152 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can create a notification in the future and when it gets called cancel all the previous ones and reschedule until you're satisfied.

  UILocalNotification* localNotification = [[UILocalNotification alloc] init];
                        localNotification.alertBody = body;
                        localNotification.timeZone = [NSTimeZone defaultTimeZone];
                        localNotification.fireDate = [NSDate new]; //<-Set the date here in 10seconds for example
 [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

Then in application didReceiveLocalNotification:(UILocalNotification *)notification:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    application cancelAllLocalNotifications;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...