ACNotificationManager Class Reference

Inherits from NSObject
Declared in ACNotificationManager.h

+ initWithAppkey:launchOptions:

初始化友盟所有组件产品

+ (void)initWithAppkey:(NSString *_Nullable)appKey channel:(NSString *_Nullable)channel

Parameters

appKey

主站生成appKey

channel

渠道标识,可设置nil表示"App Store".

Declared In

ACNotificationManager.h

+ registerForRemoteNotificationsWithLaunchOptions:

友盟推送的注册接口;

+ (void)registerForRemoteNotificationsWithLaunchOptions:(NSDictionary * __nullable)launchOptions Entity:(UMessageRegisterEntity * __nullable)entity completionHandler:(void (^ __nullable)(BOOL granted, NSError *_Nullable error))completionHandler

Parameters

launchOptions

系统的launchOptions启动消息参数用于处理用户通过消息打开应用相关信息

entity

友盟推送的注册类如果使用默认的注册,Entity设置为nil即可。如需其他的可选择其他参数,具体的参考demo或者文档

completionHandler

iOS10授权后的回调

Declared In

ACNotificationManager.h

+ registerRemoteNotificationWithTarget:authorizationOptions:completionHandler:

iOS10及以上版本的推送。 默认的时候是sound,badge ,alert三个功能全部打开。

+ (void)registerRemoteNotificationWithTarget:(id)target authorizationOptions:(UNAuthorizationOptions)options completionHandler:(void ( ^ ) ( BOOL granted , NSError *__nullable error ))completionHandler

Parameters

options

iOS10及以上版本的推送类型。默认types10 = UNAuthorizationOptionBadge|UNAuthorizationOptionAlert|UNAuthorizationOptionSound;

completionHandler

用户点击授权结果回调。

Declared In

ACNotificationManager.h

+ unregisterForRemoteNotifications

解除RemoteNotification的注册(关闭消息推送,实际调用:[[UIApplication sharedApplication] unregisterForRemoteNotifications])

+ (void)unregisterForRemoteNotifications

Parameters

types

消息类型,参见UIRemoteNotificationType

Declared In

ACNotificationManager.h

+ registerDeviceToken:

向友盟注册该设备的deviceToken,便于发送Push消息

+ (void)registerDeviceToken:(NSData *)deviceToken

Parameters

deviceToken

APNs返回的deviceToken

Declared In

ACNotificationManager.h

+ didReceiveRemoteNotification:

应用处于运行时(前台、后台)的消息处理

+ (void)didReceiveRemoteNotification:(NSDictionary *)userInfo

Parameters

userInfo

消息参数

Declared In

ACNotificationManager.h

+ setNotificationClickForRemoteNotification:

为某个消息发送点击事件

+ (void)setNotificationClickForRemoteNotification:(NSDictionary *)userInfo

Parameters

userInfo

消息体的NSDictionary,此Dictionary是 (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo中的userInfo

Discussion

Warning: 请注意不要对同一个消息重复调用此方法,可能导致你的消息打开率飚升,此方法只在需要定制 Alert 框时调用

Declared In

ACNotificationManager.h

+ addAliasWithUserId:callback:

添加推送别名

+ (void)addAliasWithUserId:(NSInteger)userId callback:(void ( ^ ) ( NSError *error ))callback

Parameters

userId

用户ID

callback

返回结果的监听回调

Declared In

ACNotificationManager.h

+ removeAliasWithUserId:callback:

若要使用新的别名,请先调用removeAlias接口移除掉旧的别名

+ (void)removeAliasWithUserId:(NSInteger)userId callback:(void ( ^ ) ( NSError *error ))callback

Parameters

userId

用户ID

callback

返回结果的监听回调

Declared In

ACNotificationManager.h