当先锋百科网

首页 1 2 3 4 5 6 7

1, 需要用桥接文件 , 不然引用不到依赖库

2, 可以用测试模式测试, 可以debug

3, 测试模式获取deviceToken, 添加测试设备

deviceToken获取方法

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let device = NSData.init(data: deviceToken)

    var deviceId = String()
    if #available(iOS 13.0, *) {
        let bytes = [UInt8](deviceToken)
        for item in bytes {
            deviceId += String(format: "%02x", item&0x000000FF)
        }
        print("iOS 13 deviceToken:\(deviceId)")
    } else {
        let device = NSData(data: deviceToken)
        deviceId = device.description.replacingOccurrences(of:"<", with:"").replacingOccurrences(of:">", with:"").replacingOccurrences(of: " ", with:"")
        print("我的deviceToken:\(deviceId)")
    }

    }