zoukankan      html  css  js  c++  java
  • ios 远程推送

     1. // 注册远程通知服务(第一次注册服务的时候会弹出提醒框,让用户授权)

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // 注册远程通知服务(第一次注册服务的时候会弹出提醒框,让用户授权)
        [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
        
      // 添加一个label,检查启动方式 UILabel
    *label = [[UILabel alloc] init]; label.backgroundColor = [UIColor lightGrayColor]; label.frame = CGRectMake(0, 100, 320, 300); label.font = [UIFont systemFontOfSize:15]; label.numberOfLines = 0; [self.window.rootViewController.view addSubview:label]; NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]; if (userInfo) { label.text = [userInfo description]; } else { label.text = @"直接点击app图标启动的程序"; } return YES; }

    2.获取设备的deviceToken

    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
    {
        NSLog(@"注册远程通知成功----%@", deviceToken);
        /**
         1.将deviceToken发送给公司的服务器
        c330833f 248c4fed e87068b6 c4b90ee8 a2b57119 aac2b93d 3f2eb27f e7d44c8c
        c330833f 248c4fed e87068b6 c4b90ee8 a2b57119 aac2b93d 3f2eb27f e7d44c8c
    
    }

    3.接收到远程推送通知时就会调用

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    {
      // 在这里读取远程通知的一些内容 NSLog(@"接收到远程通知--%@", userInfo[@"userInfo"]); }
  • 相关阅读:
    [android 应用框架api篇] bluetooth
    [uiautomator篇] bluetooth---接口来做
    [uiautomator篇] 设置@test的执行顺序
    [automator学习篇]android 接口-- bluetooth
    SharePoint : 使用SPQuery对象时要注意的事项
    SharePoint 2013版本功能对比介绍
    SharePoint Srver 2010 资源汇总
    实现简单的WebPart
    GAC的理解及其作用
    Bat命令学习
  • 原文地址:https://www.cnblogs.com/shen5214444887/p/5188843.html
Copyright © 2011-2022 走看看