Control the apple notification click when the initiator programm is not running

StackOverflow https://stackoverflow.com/questions/23632864

  •  21-07-2023
  •  | 
  •  

Вопрос

My product works as following:

  1. My application opens notification
  2. My application exits

Now, when the user clicks the notification, my application is opened again. I DONT WANT it. I want that if user clicks the notification - it will just disappear

I found there is a callback for that (and it works)

- (void)userNotificationCenter:(NSUserNotificationCenter *)center  didActivateNotification:(NSUserNotification *)notification
{
    [center removeDeliveredNotification: notification];
}

but it works only when my application is running.

Is it possible to implement the behavior I want at all?

Это было полезно?

Решение

No it isn't possible to avoid having your application launched when a user touches your notification.

The application will always be launched in response to touching a notification and the UIApplicationDelegate method application:willFinishLaunchingWithOptions: will always be called when the application is not running.

Your app doesn't have to action on the notification, but it will be launched.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top