Firebase
Introduction¶
Make sure that you already created certificate on your Apple account via previous title.
Firebase¶
- Create a project as follows :
- Select iOS icon :
- Once you've entered your package name, put the GoogleService-Info.plist file in the root directory as shown in the image download step :
- Add the following repository URL to your packages:
- Add to your AppDelegate class file:
- Go back to the main page and click on the project settings :
- Select cloud messaging then in iOS app configuration, click on upload in APNs Certificates (You need to upload the .p12 file) :
-
After opening the project in Xcode, click on the project on the left side.
-
Select Capabilities and Activate push notification
Segmentify Configuration Step¶
Please refer to this page for Segmentify configuration process.
Permission Info¶
Used to send deviceToken of users who give push permission.
// MARK: - MessagingDelegate
extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
print("FCM registration token retrieved: \(String(describing: fcmToken))")
NotificationCenter.default.post(name: .fcmTokenUpdated, object: fcmToken)
// Send FCM token info to Segmentify
let obj = NotificationModel()
obj.deviceToken = fcmToken ?? ""
obj.type = NotificationType.PERMISSION_INFO
obj.providerType = ProviderType.FIREBASE
SegmentifyManager.sharedManager().sendNotification(segmentifyObject: obj)
}
}
Click¶
It will be sent when the user clicks notification.
We need to send data to the page after clicking :
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
// send click info to Segmentify
let obj = NotificationModel()
obj.deviceToken = ""
obj.type = NotificationType.CLICK
obj.providerType = ProviderType.FIREBASE
obj.instanceId = userInfo["instanceId"] as? String ?? ""
obj.productId = userInfo["productId"] as? String ?? ""
SegmentifyManager.sharedManager().sendNotification(segmentifyObject: obj)
completionHandler()
}
}
instanceId and productId will be in the notification data
Information for Analytic Platform¶
This information is available if push information is sent to analytic platform
The UTMmodel class is as follows :
public class UtmModel {
public var utm_source:String?
public var utm_medium:String?
public var utm_campaign:String?
public var utm_content:String?
}
See our sample application : Example
Example AppDelegate : Example AppDelegate