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"]); }
  • 相关阅读:
    最常用的排序——快速排序
    堆排序 Heap Sort
    经典排序算法
    Android studio界面相关设置
    对了解矩阵、线性变换的本质有太大帮助
    [转]grep 在文本中查找内容
    [转] PHP在不同页面之间传值的三种常见方式
    快速幂取余 [转]
    Avril Lavigne : Everybody Hurts (Ver3)
    MySQL 初始化root 密码
  • 原文地址:https://www.cnblogs.com/shen5214444887/p/5188843.html
Copyright © 2011-2022 走看看