Search code examples
iosuilocalnotificationdetect

Action From Local Notification Opened (iOS)


I've searched other questions similar to this here and I can't find any that seem to actually work. What I'm trying to do is when the user opens the app from a local notification, I need it to execute some code (such as opening the UIMessageComposer or displaying a UIAlertView). Anyone have any idea on how I would do this? Just as a note it is a local notification not a push notification.


Solution

  • You need to implement this method in you AppDelegate.m file

    - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
    

    You can do want you want in this.

    Here's a good tutorial on how to work with Local notifications. http://www.appcoda.com/ios-programming-local-notification-tutorial/