How to create a local notification, alert, timer, callback etc from within imessage application (swiftUI) when the user leaves the session.


I'm relatively new to ios development, but have quite alot of experience otherwise. So, I apologize if I have the semantics wrong here:

I have an imessage application that deals with a conversation/session and has a time limit on when an activity gets communicated to all users in a group (recipients). The application is about 85% done, and this is the last technical hurdle before getting complete.

I've tried local notifications, timer callbacks, and performExpiringActivity (in sim and devices). All work great if the user stays in the active state. however, if the user goes to another conversation (say with another user, not in the group) or presses home, none of the above
work. I'm assuming this is because the application goes inactive.

What I'd like to do is have some kind of notification/badge, alert or whatever to let the user know they need to go back to the imessage app. Or even better launch the app, and execute the callback.

Thanks in advance,

Roark

Answered by prsr in 616304022
Hi Roark,

basically, after you leave conversation (either by going to conversations list or background iMessage) your extension is getting killed so none of scheduled "work" will be fired.

I think you could try use your parent app to inform users about need for iMessage "activity", though it depends what exactly you want to achieve.
Accepted Answer
Hi Roark,

basically, after you leave conversation (either by going to conversations list or background iMessage) your extension is getting killed so none of scheduled "work" will be fired.

I think you could try use your parent app to inform users about need for iMessage "activity", though it depends what exactly you want to achieve.
Just got off a lab 1-1 session w/ an apple guy. prsr nailed it. Or so I hope. I was shown how to add an iOS container (single view) to my existing iMessage extension app. We discussed ways for the iOS part of the app to handle notifications, etc. when the extension goes inactive. Here's my reading assignments that pertain to this:

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app

https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html

Hope this helps...
How to create a local notification, alert, timer, callback etc from within imessage application (swiftUI) when the user leaves the session.
 
 
Q