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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。