zoukankan      html  css  js  c++  java
  • ios8消息快捷处理——暂无输入框

     if (isiOS8)

        {

    //ios8的远程推送注册

            NSSet *set = nil;

    #if 1

            //1.创建消息上面要添加的动作(按钮的形式显示出来)

            UIMutableUserNotificationAction *action = [[UIMutableUserNotificationAction alloc] init];

            action.identifier = @"action";//按钮的标示

            action.title=@"Accept";//按钮的标题

            action.activationMode = UIUserNotificationActivationModeForeground;//当点击的时候启动程序        

            //    action.authenticationRequired = YES;

            //    action.destructive = YES;

            UIMutableUserNotificationAction *action2 = [[UIMutableUserNotificationAction alloc] init];  //第二按钮

             action2.identifier = @"action2";

              action2.title=@"Reject";

              action2.activationMode = UIUserNotificationActivationModeBackground;//当点击的时候不启动程序,在后台处理

              action.authenticationRequired = YES;//需要解锁才能处理,如果action.activationMode = UIUserNotificationActivationModeForeground;则这个属性被忽略;

            

            action.destructive = YES;

            

    //2.创建动作(按钮)的类别集合

            UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc] init];

            category.identifier = @"alert";//这组动作的唯一标示

        

            [category setActions:@[action,action2] forContext:(UIUserNotificationActionContextMinimal)];

       //

           set = [NSSet setWithObjects:category, nil];

            

            //远程通知测试 消息体:  {"aps":{"alert":"Incoming call", "sound":"default", "badge": 1, "category":"alert"}}

            

            //"category":"alert"必须对应 category.identifier = @"alert";

            

          //本地通知测试

            UILocalNotification *notification = [[UILocalNotification alloc] init];

            

            notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:15];

            notification.timeZone=[NSTimeZone defaultTimeZone];

            notification.alertBody=@"测试推送的快捷回复";

            notification.category = @"alert";

            [[UIApplication sharedApplication]  scheduleLocalNotification:notification];

    #endif

                    

            [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)  categories:set]];

             [[UIApplication sharedApplication] registerForRemoteNotifications];

        

        }else

        {

      //ios8以前的远程推送注册

            UIRemoteNotificationType apn_type = (UIRemoteNotificationType)(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge);

            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:apn_type];

        }

    }

    -(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler

    {

        //在没有启动本App时,收到服务器推送消息,下拉消息会有快捷回复的按钮,点击按钮后调用的方法,根据identifier来判断点击的哪个按钮

    }

     -(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler

    {

        //在非本App界面时收到本地消息,下拉消息会有快捷回复的按钮,点击按钮后调用的方法,根据identifier来判断点击的哪个按钮,notification为消息内容

        NSLog(@"%@----%@",identifier,notification);

        completionHandler();//处理完消息,最后一定要调用这个代码块

    }

  • 相关阅读:
    Java高级之类结构的认识
    14.8.9 Clustered and Secondary Indexes
    14.8.4 Moving or Copying InnoDB Tables to Another Machine 移动或者拷贝 InnoDB 表到另外机器
    14.8.3 Physical Row Structure of InnoDB Tables InnoDB 表的物理行结构
    14.8.2 Role of the .frm File for InnoDB Tables InnoDB 表得到 .frm文件的作用
    14.8.1 Creating InnoDB Tables 创建InnoDB 表
    14.7.4 InnoDB File-Per-Table Tablespaces
    14.7.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量和大小
    14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小
    14.6.11 Configuring Optimizer Statistics for InnoDB 配置优化统计信息用于InnoDB
  • 原文地址:https://www.cnblogs.com/zhujin/p/3998773.html
Copyright © 2011-2022 走看看