ios能获取其他app的推送消息内容吗

ios能获取其他app的推送消息内容吗,第1张

功能说明JPush SDK 收到推送,通过广播的方式,转发给开发者App,这样开发者就可以灵活地进行处理。这个动作不是必须的。用户有需要才定义 Receiver 类来处理 SDK过来的广播。如果不做这个动作,即不写自定义 Receiver,也不在 AndroidManifestxml 里配置这个 Receiver,则默认的行为是:接收到推送的自定义消息,则没有被处理可以正常收到通知,用户点击打开应用主界面接受广播如果全部类型的广播都接收,则需要在 AndroidManifestxml 里添加如下的配置信息:<receiver android:name="Your Receiver" android:enabled="true"> <intent-filter> <action android:name="cnjpushandroidintentREGISTRATION" /> <action android:name="cnjpushandroidintentMESSAGE_RECEIVED" /> <action android:name="cnjpushandroidintentNOTIFICATION_RECEIVED" /> <action android:name="cnjpushandroidintentNOTIFICATION_OPENED" /> <category android:name="You package Name" /> </intent-filter></receiver>每个 Receiver action 详细解释如下。Action - cnjpushandroidintentREGISTRATIONSDK 向 JPush Server 注册所得到的注册 ID 。一般来说,可不处理此广播信息。要深入地集成极光推送,开发者想要自己保存App用户与JPush 用户关系时,则接受此广播,取得 Registration ID 并保存与App uid 的关系到开发者自己的应用服务器上。使用极光推送提供的别名与标签功能,是更加简单轻便的绑定App用户与JPush用户的方式,请参考文档:别名与标签使用教程。Intent 参数JPushInterfaceEXTRA_REGISTRATION_IDSDK 向 JPush Server 注册所得到的注册 全局唯一的 ID ,可以通过此 ID 向对应的客户端发送消息和通知。Bundle bundle = intentgetExtras();String title = bundlegetString(JPushInterfaceEXTRA_REGISTRATION_ID);Action - cnjpushandroidintentMESSAGE_RECEIVED收到了自定义消息 Push 。SDK 对自定义消息,只是传递,不会有任何界面上的展示。如果开发者想推送自定义消息 Push,则需要在 AndroidManifestxml 里配置此 Receiver action,并且在自己写的 BroadcastReceiver 里接收处理。Intent 参数JPushInterfaceEXTRA_TITLE保存服务器推送下来的消息的标题。对应 API 消息内容的 title 字段。对应 Portal 推送消息界面上的“标题”字段(可选)Bundle bundle = intentgetExtras();String title = bundlegetString(JPushInterfaceEXTRA_TITLE);JPushInterfaceEXTRA_MESSAGE保存服务器推送下来的消息内容。对应 API 消息内容的 message 字段。对应 Portal 推送消息界面上的"消息内容”字段。 Bundle bundle = intentgetExtras();String message = bundlegetString(JPushInterfaceEXTRA_MESSAGE);JPushInterfaceEXTRA_EXTRA保存服务器推送下来的附加字段。这是个 JSON 字符串。对应 API 消息内容的 extras 字段。对应 Portal 推送消息界面上的“自定义内容”。Bundle bundle = intentgetExtras();String extras = bundlegetString(JPushInterfaceEXTRA_EXTRA);JPushInterfaceEXTRA_CONTENT_TYPE保存服务器推送下来的内容类型。对应 API 消息内容的 content_type 字段。Bundle bundle = intentgetExtras();String type = bundlegetString(JPushInterfaceEXTRA_CONTENT_TYPE);JPushInterfaceEXTRA_RICHPUSH_FILE_PATHSDK 140 以上版本支持。富媒体通消息推送下载后的文件路径和文件名。Bundle bundle = intentgetExtras();String file = bundlegetString(JPushInterfaceEXTRA_RICHPUSH_FILE_PATH);JPushInterfaceEXTRA_MSG_IDSDK 161 以上版本支持。唯一标识消息的 ID, 可用于上报统计等。Bundle bundle = intentgetExtras();String file = bundlegetString(JPushInterfaceEXTRA_MSG_ID);Action - cnjpushandroidintentNOTIFICATION_RECEIVED收到了通知 Push。如果通知的内容为空,则在通知栏上不会展示通知。但是,这个广播 Intent 还是会有。开发者可以取到通知内容外的其他信息。Intent 参数JPushInterfaceEXTRA_NOTIFICATION_TITLE保存服务器推送下来的通知的标题。对应 API 通知内容的 n_title 字段。对应 Portal 推送通知界面上的“通知标题”字段。Bundle bundle = intentgetExtras();String title = bundlegetString(JPushInterfaceEXTRA_NOTIFICATION_TITLE);JPushInterfaceEXTRA_ALERT保存服务器推送下来的通知内容。对应 API 通知内容的 n_content 字段。对应 Portal 推送通知界面上的“通知内容”字段。Bundle bundle = intentgetExtras();String content = bundlegetString(JPushInterfaceEXTRA_ALERT);JPushInterfaceEXTRA_EXTRASDK 129 以上版本支持。保存服务器推送下来的附加字段。这是个 JSON 字符串。对应 API 通知内容的 n_extras 字段。对应 Portal 推送通知界面上的“自定义内容”字段。Bundle bundle = intentgetExtras();String extras = bundlegetString(JPushInterfaceEXTRA_EXTRA);JPushInterfaceEXTRA_NOTIFICATION_IDSDK 135 以上版本支持。通知栏的Notification ID,可以用于清除NotificationBundle bundle = intentgetExtras();int notificationId = bundlegetInt(JPushInterfaceEXTRA_NOTIFICATION_ID);JPushInterfaceEXTRA_CONTENT_TYPE保存服务器推送下来的内容类型。对应 API 消息内容的 content_type 字段。 Portal 上暂时未提供输入字段。Bundle bundle = intentgetExtras();String type = bundlegetString(JPushInterfaceEXTRA_CONTENT_TYPE);JPushInterfaceEXTRA_RICHPUSH_HTML_PATHSDK 140 以上版本支持。富媒体通知推送下载的HTML的文件路径,用于展现WebView。Bundle bundle = intentgetExtras();String fileHtml = bundlegetString(JPushInterfaceEXTRA_RICHPUSH_HTML_PATH);JPushInterfaceEXTRA_RICHPUSH_HTML_RESSDK 140 以上版本支持。富媒体通知推送下载的资源的文件名,多个文件名用 “,” 分开。 与 “JPushInterfaceEXTRA_RICHPUSH_HTML_PATH” 位于同一个路径。Bundle bundle = intentgetExtras();String fileStr = bundlegetString(JPushInterfaceEXTRA_RICHPUSH_HTML_RES);String[] fileNames = fileStrspilt(",");JPushInterfaceEXTRA_MSG_IDSDK 161 以上版本支持。 唯一标识通知消息的 ID, 可用于上报统计等。Bundle bundle = intentgetExtras();String file = bundlegetString(JPushInterfaceEXTRA_MSG_ID);Action - cnjpushandroidintentNOTIFICATION_OPENED用户点击了通知。一般情况下,用户不需要配置此 receiver action。如果开发者在 AndroidManifestxml 里未配置此 receiver action,那么,SDK 会默认打开应用程序的主 Activity,相当于用户点击桌面图标的效果。如果开发者在 AndroidManifestxml 里配置了此 receiver action,那么,当用户点击通知时,SDK 不会做动作。开发者应该在自己写的 BroadcastReceiver 类里处理,比如打开某 Activity 。Intent 参数JPushInterfaceEXTRA_NOTIFICATION_TITLE保存服务器推送下来的通知的标题。对应 API 通知内容的 n_title 字段。对应 Portal 推送通知界面上的“通知标题”字段。Bundle bundle = intentgetExtras();String title = bundlegetString(JPushInterfaceEXTRA_NOTIFICATION_TITLE);JPushInterfaceEXTRA_ALERT保存服务器推送下来的通知内容。对应 API 通知内容的n_content字段。对应 Portal 推送通知界面上的“通知内容”字段。Bundle bundle = intentgetExtras();String content = bundlegetString(JPushInterfaceEXTRA_ALERT);JPushInterfaceEXTRA_EXTRASDK 129 以上版本支持。保存服务器推送下来的附加字段。这是个 JSON 字符串。对应 API 消息内容的 n_extras 字段。对应 Portal 推送通知界面上的“自定义内容”字段。Bundle bundle = intentgetExtras();String type = bundlegetString(JPushInterfaceEXTRA_EXTRA);JPushInterfaceEXTRA_NOTIFICATION_IDSDK 135 以上版本支持。通知栏的Notification ID,可以用于清除NotificationBundle bundle = intentgetExtras();int notificationId = bundlegetInt(JPushInterfaceEXTRA_NOTIFICATION_IDJPushInterfaceEXTRA_MSG_IDSDK 161 以上版本支持。唯一标识调整消息的 ID, 可用于上报统计等。Bundle bundle = intentgetExtras();String file = bundlegetString(JPushInterfaceEXTRA_MSG_ID);代码示例public void onReceive(Context context, Intent intent) { Bundle bundle = intentgetExtras(); Logd(TAG, "onReceive - " + intentgetAction()); if (JPushInterfaceACTION_REGISTRATION_IDequals(intentgetAction())) { } else if (JPushInterfaceACTION_MESSAGE_RECEIVEDequals(intentgetAction())) { Systemoutprintln("收到了自定义消息。消息内容是:" + bundlegetString(JPushInterfaceEXTRA_MESSAGE)); // 自定义消息不会展示在通知栏,完全要开发者写代码去处理 } else if (JPushInterfaceACTION_NOTIFICATION_RECEIVEDequals(intentgetAction())) { Systemoutprintln("收到了通知"); // 在这里可以做些统计,或者做些其他工作 } else if (JPushInterfaceACTION_NOTIFICATION_OPENEDequals(intentgetAction())) { Systemoutprintln("用户点击打开了通知"); // 在这里可以自己写代码去定义用户点击后的行为 Intent i = new Intent(context, TestActivityclass); //自定义打开的界面 isetFlags(IntentFLAG_ACTIVITY_NEW_TASK); contextstartActivity(i); } else { Logd(TAG, "Unhandled intent - " + intentgetAction()); } }

这里先说UIDevice,其他想了解的可以看后面的相关链接

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9673615.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存