小编Sim*_*sen的帖子

didRegisterForRemoteNotificationsWithDeviceToken 未调用

我有以下方法来获取推送通知的 UID。可悲的是,它没有被调用。我做错了什么?推送通知的注册正在运行。错误函数未被调用。我在这里快要疯了。

extension AppDelegate {
    
    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

        // 1. Convert device token to string
        let tokenParts = deviceToken.map { data -> String in
            return String(format: "%02.2hhx", data)
        }
        let token = tokenParts.joined()
        // 2. Print device token to use for PNs payloads
        print("Device Token: \(token)")

        }
    
    func application(
        _ application: UIApplication,
        didFailToRegisterForRemoteNotificationsWithError error: Error) {
        print("Error registering notifications: (error)")
    }
}


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        UIDevice.current.beginGeneratingDeviceOrientationNotifications()
        AppearanceConfigurator.configureNavigationBar()
        UIFont.overrideInitialize() …
Run Code Online (Sandbox Code Playgroud)

apple-push-notifications swift

7
推荐指数
2
解决办法
4373
查看次数

Kotlin:如何在 RecyclerView.Adapter 中调用 getSupportFragmentManager()

我想在单击事件后调用 RecyclerView.Adapter 中的支持片段管理器,以便移动到不同的片段。我的做法:

(context as MainActivity).supportFragmentManager
                            .beginTransaction()
                            .replace(MainActivity.FRAGMENT_CONTAINER, TextScreen())
                            .commit()
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

kotlin.TypeCastException:null 无法转换为非 null 类型

你能帮助我吗?

android kotlin

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

apple-push-notifications ×1

kotlin ×1

swift ×1