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

前端 未结 4 1855
温柔的废话
温柔的废话 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条回答
  •  盖世英雄少女心
    2021-01-06 10:51

    It can be handled in application delegate method as follows, if the user taps the Action button of the notification's alert, then the following method will be called, there we can cancel the notification

    - (void)application:(UIApplication *)app
    didReceiveLocalNotification:(UILocalNotification *)notif {
    [[UIApplication sharedApplication]cancelLocalNotification:notif];
    }
    

提交回复
热议问题