zoukankan      html  css  js  c++  java
  • 通知Notification相关

    1.IOS8 注册远程通知

    if([[UIDevice currentDevice].systemVersion floatValue] >= 8.0)

                {

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

                    [[UIApplication sharedApplication] registerForRemoteNotifications];

                }else{

                    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];

                }

    certificates中,apns 证书和普通证书的区别:

    apns证书:

    apns证书是用来生成p12与苹果apns服务器通信用的,

    在appid中开启apns后上传CertificateSigningRequest.certSigningRequest后就会在certificates中生成对应的apns证书,在certificates中删除,同样会在appid中删除该apns证书。

    并且该证书不会在provisioning profile中显示。

    普通证书:如在certificates中的IOS Developer

    在生成provisioning profile签名时可选择。 

    Provisioning Profile

    在xcode上运行程序到真机需要使用改签名。

    一个Provisioning Profile文件包含了上述的所有内容:证书、App ID、设备。

    2.检测用户是否允许通知,允许哪种类型的通知

      //ios7

      [UIApplication sharedApplication].enabledRemoteNotificationTypes

      // ios8以上

        UIUserNotificationSettings *setting = [UIApplication sharedApplication].currentUserNotificationSettings;

        if (setting.types == UIUserNotificationTypeNone ) {

            NSLog(@"UIUserNotificationTypeNone");

        }

        if (setting.types & UIUserNotificationTypeAlert ) {

            NSLog(@"UIUserNotificationTypeAlert");

        }

        if (setting.types & UIUserNotificationTypeSound ) {

            NSLog(@"UIUserNotificationTypeSound");

        }

        if (setting.types & UIUserNotificationTypeBadge ) {

            NSLog(@"UIUserNotificationTypeBadge");

        }

  • 相关阅读:
    IOS基于 fmdb数据库 的简单操作应用
    App 上线被拒绝的原因有哪些?
    cocoaPods的安装以及使用
    IOS开发工程师的近期面试题
    UIButton基本介绍
    UIView 详解
    使用 Paros 抓接口
    如何在main方法中创建50000次对象
    如何将将String 转换 int
    2020年09月24号--测试登录账号15分钟有效时长
  • 原文地址:https://www.cnblogs.com/ldc529/p/4059769.html
Copyright © 2011-2022 走看看