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

    推送需要真机调试

     

    #import "AppDelegate.h"

    @interface AppDelegate ()

    @end

     

    @implementation AppDelegate

     

     

     

     

     

    //注册完毕 远程推送通知之后就会调用

    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

    {

        NSLog(@"%@",deviceToken);

    }

     

     

    //远程通知注册失败的时候就会调用

    -(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error

    {

        //常见失败的三种情况

        //1,BundliID没有用全称

        //2.描述文件没有在最后配置

        //3,AppleWWDRCA.cer 误删, 导致证书文件没有授权机构的签发

    }

     

    //接收到远程推送通知之后就会调用,前提,程序活着

    -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

    {

        NSLog(@"%@",userInfo);

    }

     

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        // Override point for customization after application launch.

        //注册通知,自动提示用户通知包含的类型

        UIUserNotificationSettings *setting=[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound categories:nil];

        [[UIApplication sharedApplication]registerUserNotificationSettings:setting];

        //注册远程推送通知 这种方法会打包 uuid appid 生成devicetoken

        [[UIApplication sharedApplication]registerForRemoteNotifications];

        

        

        //取出通知内容

        if(launchOptions[UIApplicationLaunchOptionsLocalNotificationKey])

        {

            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 300)];

            label.numberOfLines = 0;

            label.backgroundColor = [UIColor redColor];

            label.text= [NSString stringWithFormat:@"%@",launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]];

            [self.window.rootViewController.view addSubview:label];

        }

        

        

        return YES;

    }

  • 相关阅读:
    Oracle实用SQL语句
    关键字过滤(转载)
    最简单的Cache
    .net中下载文件的方法(转载)
    为SharePoint 2013配置Office Web Apps
    使用Visual Studio 部署SharePoint时提示“路径中具有非法字符”
    TFS 2012 在IE 10(Windows 8)显示英文的解决方案
    为什么使用TFS 2012进行源代码管理——TFS 2012使用简介(一)
    SharePoint 2010 在WebPart页面上调用扩展方法报方法未定义的解决方案
    TreeView结合UpdatePanel使用时,SelectedNodeStyle不生效的解决方案
  • 原文地址:https://www.cnblogs.com/tangranyang/p/4655852.html
Copyright © 2011-2022 走看看