IOS 推送

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    /* APP未启动,点击推送消息的情况下 iOS10遗弃UIApplicationLaunchOptionsLocalNotificationKey,使用代理UNUserNotificationCenterDelegate方法didReceiveNotificationResponse:withCompletionHandler:获取本地推送
    */
    // NSDictionary *localUserInfo = launchOptions[UIApplicationLaunchOptionsLocalNotificationKey];
    // if (localUserInfo) {
    // NSLog(@“localUserInfo:%@”,localUserInfo);
    // //APP未启动,点击推送消息
    // }
    NSDictionary *remoteUserInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
    if (remoteUserInfo) {
    NSLog(@“remoteUserInfo:%@”,remoteUserInfo);
    //APP未启动,点击推送消息,iOS10下还是跟以前一样在此获取
    }
    [self registerNotification];
    return YES;
    }

  • (void)registerNotification{
    /*
    identifier:行为标识符,用于调用代理方法时识别是哪种行为。
    title:行为名称。
    UIUserNotificationActivationMode:即行为是否打开APP。
    authenticationRequired:是否需要解锁。
    destructive:这个决定按钮显示颜色,YES的话按钮会是红色。
    behavior:点击按钮文字输入,是否弹出键盘
    */
    UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@“action1” title:@“策略1行为1” options:UNNotificationActionOptionForeground];
    /*iOS9实现方法
    UIMutableUserNotificationAction * action1 = [[UIMutableUserNotificationAction alloc] init];
    action1.identifier = @“action1”;
    action1.title=@“策略1行为1”;
    action1.activationMode = UIUserNotificationActivationModeForeground;
    action1.destructive = YES;
    */

    UNTextInputNotificationAction *action2 = [UNTextInputNotificationAction actionWithIdentifier:@“action2” title:@“策略1行为2” options:UNNotificationActionOptionDestructive textInputButtonTitle:@“textInputButtonTitle” textInputPlaceholder:@“textInputPlaceholder”];
    /*iOS9实现方法
    UIMutableUserNotificatio

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值