信鸽推送SDK2.4.0Swift1.2集成

开发环境:OS X Yosemite 10.10.3 + Xcode 6.4
开发语言:Swift 1.2

信鸽推送SDK2.4.0Swift1.2DemoGit地址php

使用方法


  • XinGeSDK2_4_0文件拷贝到工程中node

  • 拷贝XinGeAppDelegate.swift到工程中git

  • 工程名-Bridging-Header.h桥接文件中,添加github

#import "XGSetting.h"
#import "XGPush.h"
  • AppDelegate继承XinGeAppDelegate,而且二者有且只有一个var window: UIWindow?属性。继承的方法前须要添加override关键字,例如:sql

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)
    }
}
  • 腾讯信鸽官网建立应用并提交证书。swift

  • XinGeAppDelegate.swift文件中填写ACCESS IDACCESS KEYruby

添加必要的框架:


  • CoreGraphics.frameworkapp

  • CoreTelephony.framework框架

  • SystemConfiguration.frameworkide

  • libz.dylib

  • CFNetwork.framework

  • libsqlite3.dylib

错误及解决

  • 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 IdentityProvisioning 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,而是展开有开发者名字的子级。

  • 更多错误信息
    参考:信鸽常见问题与解答

相关文章
相关标签/搜索