zoukankan      html  css  js  c++  java
  • 推送消息出现情景和处理办法

    1. 当程序处于关闭状态收到推送消息时,点击图标会调用- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions这个方法,那么消息给通过launchOptions这个参数获取到。

      //  判断程序是不是由推送服务完成的

        if (launchOptions)

        {

            NSDictionary* pushNotificationKey = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

            if (pushNotificationKey)

            {

                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"推送通知"

                                                               message:@"这是通过推送窗口启动的程序,你可以在这里处理推送内容"

                                                              delegate:nil

                                                     cancelButtonTitle:@"知道了"

                                                     otherButtonTitles:nil, nil];

                [alert show];

                [alert release];

            }

        }

    2. 当程序处于前台工作时,这时候若收到消息推送,会调用- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo这个方法

    -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

    {

        

        

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"接收到本地提醒"

                              

                                                        message:notification.alertBody

                              

                                                       delegate:nil

                              

                                              cancelButtonTitle:notification.alertTitle

                              

                                              otherButtonTitles:notification.alertAction, nil];

        

        [alert show];

        

        //这里,你就可以通过notification的useinfo,干一些你想做的事情了

        

       // application.applicationIconBadgeNumber -= 1;

        

    }

    3. 当程序处于后台运行时,这时候若收到消息推送,如果点击消息或者点击消息图标时,也会调用- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary *)userInfo这个方法

  • 相关阅读:
    CentOS 8.2上安装Cassandra Web部署
    CentOS 8.2上安装Apache Cassandra 3.11.9
    CentOS 8.2使用pgAdmin安装PostgreSQL 13.1
    windows 服务器报错处理,TLS升级为1.2
    网站跳转index.html
    安装fail2ban,防止ssh爆破及cc攻击
    服务器数据盘挂载
    2条命令在centos7.5中安装谷歌浏览器
    部署安装python3.7
    部署安装snort--入侵检测工具
  • 原文地址:https://www.cnblogs.com/woaixixi/p/4971521.html
Copyright © 2011-2022 走看看