Answers for "capacitor cannot find instance id in scope swift"

1

capacitor cannot find instance id in scope swift

// override this code,  placed in 'AppDelegate.swift'
InstanceID.instanceID().instanceID { (result, error) in
	if let error = error {
    	NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidFailToRegisterForRemoteNotificationsWithError.name()), object: error)
	} else if let result = result {
    	NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: result.token)
	}
}
// by this
Messaging.messaging().token { (token, error) in
	if let error = error {
    	NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidFailToRegisterForRemoteNotificationsWithError.name()), object: error)
    } else if let token = token {
    	NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: token)
    }
}
Posted by: Guest on July-16-2021

Code answers related to "capacitor cannot find instance id in scope swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language