简体   繁体   English

如何知道应用程序用户是否单击了推送通知ios?

[英]How to know if app user click on push notification ios?

我想检测用户是否单击推送通知以启动应用程序。

只需在您的AppDelegate中实现方法

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;

If the application was not running the didFinishLaunchingWithOptions method gets called when the application starts and you can check the launchOptions parameters like this: 如果应用程序未运行,则在应用程序启动时会调用didFinishLaunchingWithOptions方法,您可以像下面这样检查launchOptions参数:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    if (launchOptions != nil) {
         NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
         if (notification) {
             // Launched from push notification
         }

    }
}

If the application is already launched you can use this method: 如果应用程序已经启动,则可以使用以下方法:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground  )
    {
         //opened from a push notification when the app was on background
    }
}

You can also check: Detect if the app was launched/opened from a push notification 您还可以检查: 通过推送通知检测应用程序是否已启动/打开

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何知道是否使用Pushsharp将推送通知传递到iOS应用程序? - How to Know whether Push Notification Delivered or not to an iOS app using Pushsharp? iOS-如何在iOS应用上跟踪用户对推送通知的选择? - iOS - How to track user choice for push notification on an iOS app? 当用户直接点击应用程序时如何获取推送通知消息? - How to get push notification message when the user click the App directly? iOS推送通知点击导致应用崩溃 - iOS push notification click causes app to crash 如何在解析iOS应用中阻止特定的用户推送通知? - How to block specific user push notification in parse iOS app? iOS推送通知-单击应用程序图标而不是通知时如何获取通知数据 - iOS Push Notification - How to get the notification data when you click on the app icon instead of notification 如何处理 iOS Swift 中的推送通知点击? - How to handle push notification click in iOS Swift? 如何知道应用程序何时收到通知以及用户何时在iOS中点击通知 - How to know when app received notification and when user clicked on notification in iOS iOS / XCode:如何通过点击通知或跳板应用程序图标来了解该应用程序已启动? - iOS / XCode: how to know that app has been launched with a click on notification or on springboard app icon? iOS推送通知:如何在应用程序处于后台时检测用户是否点击了通知? - iOS push notification: how to detect if the user tapped on notification when the app is in background?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM