友盟集成接口使用说明
优质
小牛编辑
129浏览
2023-12-01
(1)应用开启推送、注册通知方法
//友盟推送代码
UMessageRegisterEntity * entity = [[UMessageRegisterEntity alloc] init];
//type是对推送的几个参数的选择,可以选择一个或者多个。默认是三个全部打开,即:声音,弹窗,角标
entity.types = UMessageAuthorizationOptionBadge|UMessageAuthorizationOptionSound|UMessageAuthorizationOptionAlert;
if (@available(iOS 10.0, *)) {
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
} else {
// Fallback on earlier versions
}
[UMessage registerForRemoteNotificationsWithLaunchOptions:launchOptions Entity:entity completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
//用户开启推送
}else
{
//用户不允许推送
}
}];
(2) 友盟注册deviceToken
// deviceToken 注册推送后下发的deviceToken
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
[UMessage registerDeviceToken:deviceToken];
[[NtalkerPushManager sharedPushManager] ntalker_pushDeviceToken:deviceToken isProduction:self.isProduction];
}