码迷,mamicode.com
首页 > 移动开发 > 详细

ios8,xcode6 周边

时间:2014-09-19 15:27:45      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   io   os   使用   ar   

NSBundle.mainBundle().infoDictionary

iOS 8中带按钮的推送代码

bubuko.com,布布扣
 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时调用

bubuko.com,布布扣
 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; 
      }  
    );  
}  

ios8,xcode6 周边

标签:des   style   blog   http   color   io   os   使用   ar   

原文地址:http://www.cnblogs.com/loganv/p/3981334.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!