Search code examples
iosapple-push-notificationsmfmessagecomposeviewcontroller

Open iMessage composer after clicking app's notification banner?


I'm looking for a way to set up an iMessage after a user clicks my app's notification. Is there any way to do it directly, or would the notification have to open my app and then open MFMessageComposeVC? If I can only do the latter, how can I distinguish the user opening my app from a notification vs from clicking the icon? Could I pass information into my app, such as who to send the message to?

Thanks in advance.


Solution

  • Is there any way to do it directly, or would the notification have to open my app and then open MFMessageComposeVC?

    No, it will have to open your app first which in term will open MFMessageComposerVC.

    If I can only do the latter, how can I distinguish the user opening my app from a notification vs from clicking the icon?

    Yes, if the user opens the app from the notification, the application:didReceiveRemoteNotification will be executed. If the user opens in the traditional way, the application:didFinishLaunchingWithOptions will be executed, the launchOptions dictionary will contain your notification info.

    Could I pass information into my app, such as who to send the message to?

    Yes, you can pass information to your app through Push Notifications.


    For further information, you you can refer to this tutorial,which even though is for iOS 6, it explains how Notification work and is a good starting point for you.