1

Je sais que cette question semble double mais je n'ai pas trouvé la réponse exacte par mon application requirement.Doing liées à des événements médicaux avec les étapes ci-dessous, suiviIOS: méthode d'appel lorsque la notification locale est reçue en arrière-plan

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 

Tout fonctionne correctement lorsque l'application est en premier plan et lorsque l'application atteint l'arrière-plan, seules les notifications locales sont envoyées. Aucun message n'est reçu par l'utilisateur.Parce qu'aucune méthode n'appelle lorsque l'application est en arrière-plan.Mais mon application dépend principalement lors de l'envoi de sms.

Y at-il une solution pour cela? Toute aide sera la bienvenue! Thnxx !!

Répondre

1

Vous devrez explicitement exécuter votre méthode dans une UIBackgroundTask. Voir l'exemple ci-dessous:

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; 

Je fais quelque chose de similaire et cela fonctionne pour moi. Faites-moi savoir si cela ne fonctionne pas pour vous.

+0

Salut merci pour répondre et j'ai eu des doutes quand la notification locale a tiré en arrière-plan à un certain moment toute méthode de délégué sera appelée –