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");

        }

  • 相关阅读:
    MVC的各个部分都有那些技术来实现?如何实现?
    JRE、JDK、JVM 及 JIT 之间有什么不同
    什么是竞态条件?举例说明
    【Spring】No converter found for return value of type: class java.util.ArrayList
    【Spring】org.springframework.web.context.ContextLoaderListen 报错
    【Spring】The matching wildcard is strict……
    【MySQL】目录、文件权限问题
    线程和锁
    【Git】Found a swap file by the name ".git/.MERGE_MSG.swp"
    【Maven】Mac 使用 zsh 后 mvn 命令就无效
  • 原文地址:https://www.cnblogs.com/ldc529/p/4059769.html
Copyright © 2011-2022 走看看