# JPush Swift Demo
Offically supported Swift Demo for JPush iOS SDK.
## JPush SDK 集成步骤
#### 添加工程文件到
![image](https://github.com/jpush/jpush-swift-demo/blob/master/ReadMeRecource/添加jpushSDK到工程中%20.gif)
#### 在工程中新建一个 Objective-C Bridging Header 文件
![image](https://github.com/jpush/jpush-swift-demo/blob/master/ReadMeRecource/生成ObjCBridge文件.gif)
#### 在刚生成的Objective-C Bridging Header文件中导入 jpush 头文件
![image](https://github.com/jpush/jpush-swift-demo/blob/master/ReadMeRecource/在ObjctBridgingHeader添加sdk头文件.gif)
#### 在Link Binary with Libraries 添加下图的依赖库
![image](https://github.com/jpush/jpush-swift-demo/blob/master/ReadMeRecource/添加依赖库文件.png)
#### 在Appdelegate.swift 文件的 didFinishLaunching 方法中添加如下代码
```
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0) {
// 可以自定义 categories
JPUSHService.registerForRemoteNotificationTypes(UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Alert.rawValue , categories: nil)
} else {
JPUSHService.registerForRemoteNotificationTypes(UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Alert.rawValue , categories: nil)
}
JPUSHService.setupWithOption(launchOptions, appKey: appKey, channel: channel, apsForProduction: isProduction)
return true
}
```
#### 在Appdelegate.swift 文件的 didRegisterForRemoteNotificationsWithDeviceToken 方法中添加如下代码
```
func application(application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
print("get the deviceToken \(deviceToken)")
NSNotificationCenter.defaultCenter().postNotificationName("DidRegisterRemoteNotification", object: deviceToken)
JPUSHService.registerDeviceToken(deviceToken)
}
```
到此 已经完成集成 JPush sdk 的基本功能,若需要更多功能请参考Demo工程
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
官方Demo: https://github.com/jpush/jpush-swift-demo 运行会报错,报错是因为networkDidReceiveMessage方法的notification数据解析报错,可一步步排查 测试只需要把项目里的appKey改成你自己的就可以测试了
资源推荐
资源详情
资源评论
收起资源包目录
jpush-swift-demo-master.zip (47个子文件)
jpush-swift-demo-master
JPushSwiftDemo
jpush-ios-2.1.0.a 9.75MB
Assets.xcassets
AppIcon.appiconset
iphone1x.png 15KB
Contents.json 2KB
ipad1x.png 23KB
iphone2x.png 54KB
ipadmini1x.png 25KB
ipadmini2x.png 93KB
iphone7.png 59KB
ipad2x.png 84KB
RootViewController.swift 6KB
setLocalNotificationViewController.swift 3KB
SendBadgeViewController.swift 1KB
Base.lproj
LaunchScreen.storyboard 2KB
Main.storyboard 56KB
SetTagsViewController.swift 4KB
Recource
icon
iphone1x.png 15KB
ipad1x.png 23KB
ios7.png 59KB
iphone2x.png 54KB
ipadmini1x.png 25KB
ipadmini2x.png 93KB
ipad2x.png 84KB
tabBarImage
setTags.png 3KB
report.png 3KB
localNotification.png 3KB
index.png 3KB
AppDelegate.swift 3KB
JPushSwiftDemo-Bridging-Header.h 129B
Info.plist 2KB
JPUSHService.h 11KB
JPushSwiftDemoTests
JPushSwiftDemoTests.swift 995B
Info.plist 733B
JPushSwiftDemo.xcodeproj
project.xcworkspace
contents.xcworkspacedata 159B
xcuserdata
wangyu.xcuserdatad
UserInterfaceState.xcuserstate 11KB
project.pbxproj 32KB
xcuserdata
wangyu.xcuserdatad
xcschemes
xcschememanagement.plist 666B
JPushSwiftDemo.xcscheme 4KB
ReadMeRecource
添加依赖库文件.png 150KB
生成ObjCBridge文件.gif 1.03MB
添加jpushSDK到工程中 .gif 558KB
在ObjctBridgingHeader添加sdk头文件.gif 237KB
LICENSE 1KB
.DS_Store 6KB
.gitignore 1KB
README.md 2KB
JPushSwiftDemoUITests
JPushSwiftDemoUITests.swift 1KB
Info.plist 733B
共 47 条
- 1
资源评论
- panwei_ios2016-11-25你那有OC版本的demo,急求,可以出金币买
罗小成
- 粉丝: 5
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功