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

转载于:https://www.cnblogs.com/loganv/p/3981334.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值