Is it possible to stop the sound of a UILocalNotification from playing when the notification is delivered?

前端 未结 4 1828
温柔的废话
温柔的废话 2021-01-06 10:17

If a UILocalNotification fires with a sound set, and the user taps \"Cancel\" on the notification alert, the sound is stopped. But if the user taps \"View\", iOS then del

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-06 10:43

    It does not stop on the device too (5.1)

    I have been trying to fix it but I can't figure it out.

    I actually got it to stop on the simulator using this

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.
        UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
        if (localNotif) {
            [[UIApplication sharedApplication] cancelLocalNotification:localNotif];
        }    
        return YES;
    }
    

    but It still doesn't stop on the device

提交回复
热议问题