• ios8,xcode6 周边


    NSBundle.mainBundle().infoDictionary

    iOS 8中带按钮的推送代码

     1 if ( UIDevice.currentDevice().systemVersion.hasPrefix("7") ){
     2             
     3             application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound)
     4         }else {
     5             
     6             var userNotificationAction = UIMutableUserNotificationAction()
     7             userNotificationAction.activationMode = .Foreground
     8             userNotificationAction.identifier = "identifier1"
     9             userNotificationAction.title = "打开程序"
    10 
    11             var userNotiAction = UIMutableUserNotificationAction()
    12             userNotiAction.activationMode = .Background
    13             userNotiAction.identifier = "identifier2"
    14             userNotiAction.title = "发送消息"
    15             userNotiAction.authenticationRequired = false
    16             userNotiAction.destructive = true
    17             
    18             
    19             var category = UIMutableUserNotificationCategory()
    20             category.identifier = "idCategory"
    21             category.setActions([userNotificationAction,userNotiAction], forContext: .Default)
    22             
    23             var userNotiSet = UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge , categories: NSSet(object: category))
    24             application.registerUserNotificationSettings(userNotiSet)
    25             
    26             application.registerForRemoteNotifications()
    27         }
    swift Code

    category.identifier 服务器推送的json为

    {"aps":{"category":"idCategory","alert":"alert","badge":"1","sound":"default"}}

    之后会根据 推送的category 显示哪个UIMutableUserNotificationCategory,当点击UIMutableUserNotificationAction时调用

     1 func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [NSObject : AnyObject], completionHandler: () -> Void) {
     2         
     3         println(identifier,userInfo)
     4         
     5         if identifier == "identifier2" {
     6             
     7             var dat = NSData(contentsOfURL: NSURL(string: "http://121.199.28.164/llc/api/?req=userList"))
     8             var str = NSString(data: dat, encoding: NSUTF8StringEncoding)
     9             println(str)
    10         }
    11         
    12         completionHandler()
    13     }
    swift Code

     

     

    iOS 8中使用Swift和Xcode 6制作精美的UI组件

    http://www.cocoachina.com/industry/20140619/8883.html

     

    1、用 POST 方式发送请求:
    http://itunes.apple.com/search?term=你的应用程序名称&entity=software

    2、更简单的请求, 根据appid,查询返回结果

    http://itunes.apple.com/lookup?id=[appid]

    {  
        resultCount = 1;  
        results =     (  
                    {  
                artistId = 开发者 ID;  
                artistName = 开发者名称; 
                price = 0; 
                isGameCenterEnabled = 0;  
                kind = software;  
                languageCodesISO2A =             (  
                    EN  
                ); 
                trackCensoredName = 审查名称;  
                trackContentRating = 评级;  
                trackId = 应用程序 ID;  
                trackName = 应用程序名称";  
                trackViewUrl = 应用程序介绍网址;  
                userRatingCount = 用户评级;  
                userRatingCountForCurrentVersion = 1;  
                version = 版本号;  
                wrapperType = software; 
          }  
        );  
    }  

  • 相关阅读:
    Linux Window Redis安装
    Mysql 死锁的详细分析方法
    mariadb rpm 安装
    我希望我能做到:我只是认真--做技术的人,对待技术,应该拥有什么样的态度?
    Google140道面试题
    mysql my.cnf配置文件详解
    Linux iostat字段解析
    Linux mpstat字段解析
    Selenium入门8 js调用
    Selenium入门7 内嵌框架iframe
  • 原文地址:https://www.cnblogs.com/loganv/p/3981334.html
Copyright © 2020-2023  润新知