ios8,xcode6 周边

时间:2023-03-09 19:08:26
ios8,xcode6 周边

NSBundle.mainBundle().infoDictionary

iOS 8中带按钮的推送代码

 if ( UIDevice.currentDevice().systemVersion.hasPrefix("") ){

             application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound)
}else { var userNotificationAction = UIMutableUserNotificationAction()
userNotificationAction.activationMode = .Foreground
userNotificationAction.identifier = "identifier1"
userNotificationAction.title = "打开程序" var userNotiAction = UIMutableUserNotificationAction()
userNotiAction.activationMode = .Background
userNotiAction.identifier = "identifier2"
userNotiAction.title = "发送消息"
userNotiAction.authenticationRequired = false
userNotiAction.destructive = true var category = UIMutableUserNotificationCategory()
category.identifier = "idCategory"
category.setActions([userNotificationAction,userNotiAction], forContext: .Default) var userNotiSet = UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge , categories: NSSet(object: category))
application.registerUserNotificationSettings(userNotiSet) application.registerForRemoteNotifications()
}

swift Code

category.identifier 服务器推送的json为

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

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

 func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [NSObject : AnyObject], completionHandler: () -> Void) {

         println(identifier,userInfo)

         if identifier == "identifier2" {

             var dat = NSData(contentsOfURL: NSURL(string: "http://121.199.28.164/llc/api/?req=userList"))
var str = NSString(data: dat, encoding: NSUTF8StringEncoding)
println(str)
} completionHandler()
}

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