跳到主要内容

上报推送数据

APNs 推送通道的到达设备、点击通知数据,需要终端主动上报数据后才能获取统计数据,从 SDK 5.1.4 版本开始,融云 iOS SDK 提供了上报数据接口。

提示

推送数据统计功能仅针对已上线应用的生产环境。如果是海外数据中心的应用,请根据 SDK 版本完成配置,确保数据上报到正确的数据中心,详见知识库文档融云海外数据中心使用指南

上报推送到达数据

通过 recordReceivedRemoteNotificationEvent: 接口上报推送送达数据。iOS 10 以上系统版本支持此能力。暂仅支持上报单聊、群聊会话类型的推送到达数据,不支持上报超级群推送和不落地推送到达数据。

/*!
统计收到远程推送的事件

@param userInfo 远程推送的内容

@discussion 此方法用于统计融云推送服务的到达率。
如果您需要统计推送服务的到达率,需要在 App 中实现通知扩展,并在 NotificationService 的 -didReceiveNotificationRequest: withContentHandler: 中
先初始化 appkey 再调用此方法并将推送内容 userInfo 传入即可。

@discussion 如果有单独的统计服务地址,还需要在初始化之后设置独立的统计服务地址

如:

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];

NSDictionary *userInfo = self.bestAttemptContent.userInfo;
[[RCCoreClient sharedCoreClient] initWithAppKey:RONGCLOUD_IM_APPKEY];
if (RONGCLOUD_STATS_SERVER.length > 0) {
[[RCCoreClient sharedCoreClient] setStatisticServer:RONGCLOUD_STATS_SERVER];
}
[[RCCoreClient sharedCoreClient] recordReceivedRemoteNotificationEvent:userInfo];

self.contentHandler(self.bestAttemptContent);
}

@remarks 高级功能
*/
- (void)recordReceivedRemoteNotificationEvent:(NSDictionary *)userInfo;

上报推送点击数据

通过 recordRemoteNotificationEvent 接口上报远程推送通知点击数据。

/*!
统计远程推送的点击事件

@param userInfo 远程推送的内容

@discussion 此方法用于统计融云推送服务的点击率。
如果您需要统计推送服务的点击率,只需要在 AppDelegate 的-application:didReceiveRemoteNotification:中,
调用此方法并将 launchOptions 传入即可。

@remarks 高级功能
*/
- (void)recordRemoteNotificationEvent:(NSDictionary *)userInfo;