Receive Push Messages
The iOS SDK can receive push messages through FCM (which uses APNs). To set up a Firebase Project to user FCM, refer to the FCM iOS documentation and follow it completely. Make sure to also configure APNs with FCM.
Once you have done that, add your GoogleService-Info.plist to the root of your xcode project.
To register your FCM token with Mitter, do the following:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("APNs token retrieved: \(deviceToken.base64EncodedString())")
InstanceID.instanceID().instanceID { (result, error) in
if let error = error {
print("Error fetching remote instange ID: \(error)")
} else if let result = result {
print("Remote instance ID token: \(result.token)")
self.mitter.registerFcmToken(token: result.token) {
result in
switch result {
case .success(let deliveryEndpoint):
print("Endpoint is: \(deliveryEndpoint.serializedEndpoint)")
case .error:
print("Unable to register endpoint!")
}
}
}
}
// With swizzling disabled you must set the APNs token here.
// Messaging.messaging().apnsToken = deviceToken
}To receive Messages when the app is in the background and then add it into the Channel view, do the following:
To receive messages directly from FCM (and not via APNs push), do the following:
Here is the function (used in the above snippets) that will add the parsed FCM message into the Channel View. Add it to your AppDelegate. Refer to the upcoming sections on the structure of the storyboard and ChannelWindowViewController:
Last updated