Skip to content

Firebase

Introduction

Make sure that you already created certificate on your Apple account via previous title.

Firebase


  • Create a project as follows :

Firebase Console

Add Project Add Project Add Project

  • Select iOS icon :

Select OS

  • Once you've entered your package name, put the GoogleService-Info.plist file in the root directory as shown in the image download step :

Download Config

  • Add the following repository URL to your packages:

Gradle Config

  • Add to your AppDelegate class file:

Ios Init Config

  • Go back to the main page and click on the project settings :

Project Settings

  • Select cloud messaging then in iOS app configuration, click on upload in APNs Certificates (You need to upload the .p12 file) :

p12 upload

  • After opening the project in Xcode, click on the project on the left side.

  • Select Capabilities and Activate push notification

Sgf Push Settings

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

var utm_model = SegmentifyManager.sharedManager().getTrackingParameters();

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