代码之家  ›  专栏  ›  技术社区  ›  Mick Walker

iPhone iPhone SDK推送通知

  •  2
  • Mick Walker  · 技术社区  · 15 年前

    我的iPhone应用程序是否可以获取上次发送给它的推送通知的内容?

    基本上,我想根据收到的通知类型执行特定的操作。

    1 回复  |  直到 13 年前
        1
  •  2
  •   coneybeare    15 年前

    在推送通知中,您可以发送一个“有效负载”,它在打开时传输到您的应用程序:

    您的应用程序应获取“userinfo”(nsdictionary)作为didFinishLaunchWithOptions()方法的参数。

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    Parameters
    application
    The application interested in the remote notification.
    userInfo
    A dictionary that contains information related to the remote notification, potentially including a badge number for the application icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data. The provider originates it as a JSON-defined dictionary that iPhone OS converts to anNSDictionary object; the dictionary may contain only property-list objects plus NSNull.
    

    要设置有效载荷,请参见 Apple Push Notification Service Programming Guide .基本上,你可以在那里发送任何类型的信息来帮助应用程序在内部将用户路由到正确的位置。