zoukankan      html  css  js  c++  java
  • iOS 本地通知 操作

    iOS 本地通知 操作

    1:配置通知:然后退出程序;

    UILocalNotification *localNotif = [[UILocalNotification alloc] init];
    localNotif.fireDate = date;  // date after 10 sec from now
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    
    // Notification details
    localNotif.alertBody =  text; // text of you that you have fetched
    // Set the action button
    localNotif.alertAction = @"View";
    
    localNotif.soundName = UILocalNotificationDefaultSoundName;
    localNotif.applicationIconBadgeNumber = 1;
    
    // Specify custom data for the notification
    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
    localNotif.userInfo = infoDict;
    
    // Schedule the notification
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

    2:接收通知,打开操作

        - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // Override point for customization after application launch.
    
    // Add the view controller's view to the window and display.
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
    
    application.applicationIconBadgeNumber = 0;
    
    // Handle launching from a notification
    UILocalNotification *localNotif =
    [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    if (localNotif) {
        NSLog(@"Recieved Notification %@",localNotif);
    }
    
    return YES;
           }
    
      - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification  *)notif {
    // Handle the notificaton when the app is running
    NSLog(@"Recieved Notification %@",notif);
           }

    参考:http://stackoverflow.com/questions/19357087/how-to-display-notifications-in-status-bar-using-dynamic-data-in-iphone

  • 相关阅读:
    html与app交互
    算法:算法的时间与空间复杂度
    php加解密函数集合
    redis主要用法
    【原创】RabbitMQ教程:php实现
    安装RabbitMq
    mysql复制表和字段
    vim文本操作
    JAVA学习(常量)
    JAVA学习(变量)
  • 原文地址:https://www.cnblogs.com/cocoajin/p/3524934.html
Copyright © 2011-2022 走看看