开发环境:OS X Yosemite 10.10.3 + Xcode 6.4
开发语言:Swift 1.2
信鸽推送SDK2.4.0Swift1.2DemoGit地址
使用方法
#import "XGSetting.h"
#import "XGPush.h"
import UIKit
@UIApplicationMain
class AppDelegate: XinGeAppDelegate{
var window: UIWindow?
override func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
// 在此处,可以设置UI等操作。
return super.application(application,didFinishLaunchingWithOptions: launchOptions)
}
}
添加必要的框架:
错误及解决
Xcode输出信息:You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:],but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist. 解决:Target-->点击Capabilities -->打开Background Modes -->勾选Remote notification ,步骤及最终结果如下图
Xcode输出:didFailToRegisterForRemoteNotifications error:未找到应用程序的“aps-environment”的授权字符串 原因:没有相应的证书 解决1(传统方法):下载相应的证书-->双击后自动安装-->Build Settings-->Code Signing-->设置Code Signing Identity 和Provisioning Profile 解决2(确保在开发中心已经有对应的证书):点击屏幕左上角的Xcode -->Preferences... (快捷键:command +, )-->选择Apple IDs中你需要的ID-->点击View Details... -->点左下角的刷新按钮。如下面图片操作:
-
创建通知-->测试预览,出现failed to load certificate,check your APNS certificate ;创建通知-->确定推送,出现apns cert error! . 原因:.pem证书生成时出现错误。信鸽官方解释 情况一:生成.pem证书时,命令没有输入完全,缺少了 -nodes ,完成的命令为: openssl pkcs12 -in Your_APNS_DEV.p12 -out Your_APNS_DEV.pem -nodes 情况二:导出.p12证书时,选中的不是Apple Developmetn IOS Push Services:your.app.bundleidentifier ,而是展开有开发者名字 的子级。
更多错误信息 参考:信鸽常见问题与解答
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|