1

我知道这个问题看起来是重复的,但我没有按照我的要求找到确切的答案。按照以下步骤进行与医疗事件相关的应用程序

1) connected the app to smart watch.

2) schedule the local notifications i. e when user needs to take
medicine 

3) when the schedule time arrives local notification fires and
delegate method is calling (did receive local notification)

4) At the time of  firing local notifications i am sending
message(sms) to the user from the app  that he has to take certain
medicine

当应用程序处于前台并且当应用程序到达后台时,一切正常关于发送短信。

有什么解决方案吗?欢迎任何帮助!谢谢!

4

1 回答 1

2

您将需要在 UIBackgroundTask 中显式运行您的方法。请参见下面的示例:

    UIApplication * application = [UIApplication sharedApplication];
    UIBackgroundTaskIdentifier background_task;
    background_task = [application beginBackgroundTaskWithExpirationHandler:^ {
        [application endBackgroundTask: background_task];
        background_task = UIBackgroundTaskInvalid;
    }];

    // your method call here

    [application endBackgroundTask: background_task];
    background_task = UIBackgroundTaskInvalid;

我正在做类似的事情,这对我有用。如果那不适合你,请告诉我。

于 2015-04-17T14:51:54.877 回答