Skip to main content

Embedding Firebase + Mixpanel (iOS)

M
Written by Marat Zhanabekov
Updated over 2 weeks ago

Firebase (Notification Service)

  1. SDK Implementation: Make sure that you’ve implemented the Firebase Cloud Messaging SDK according to the official documentation.

  2. Method Swizzling: Pay attention and implement the first three paragraphs of the instruction. In case you disable method swizzling, the paragraph about disabled method swizzling is also mandatory.

  3. Rich Notifications: Make sure that the app resolves images in push notifications.


Mixpanel (Integrate Analytics)

There are 2 ways to send a push_token to Mixpanel: via event + event_property, or via user_property:

⚠️ IMPORTANT
We strongly recommend triggering the push_token event logging on EVERY app start, not as a didRegisterForRemoteNotificationsWithDeviceToken callback!

ℹ️ NOTE
In case you use Firebase Push SDK, make sure that you send the Firebase registration ID (fcmToken). Do not confuse it with the APNS push token.
Example format: fVB5-GsfONYTmjsOX6POeS:APA91bGOokpBTI_aAO_JybIMfJ8WCPX_77EWVqzOlmsTm6GaUngqRf-hu_ZMXS9JptSOqBJ0Yx


Mixpanel (User Email)

To track user email addresses and enable email-based features, you must use the $email reserved property. This property is used by Mixpanel to populate the user's profile and is required for sending emails through NGrow and Mixpanel.

Implementation Steps

  1. Identify the User: Before setting any profile properties, ensure you have called identify with a unique user ID (e.g., your internal database ID).

  2. Set the Email Property: Use the people.set method to assign the email address to the $email property.

Code Examples

Swift

// 1. Identify the user Mixpanel.mainInstance().identify(distinctId: "USER_ID")  
// 2. Set the $email property Mixpanel.mainInstance().people.set(property: "$email", to: "[email protected]")

Objective-C

// 1. Identify the user [[Mixpanel sharedInstance] identify:@"USER_ID"];  
// 2. Set the $email property [[Mixpanel sharedInstance].people set:@"$email" to:@"[email protected]"];

💡 TIP
Always call identify before people.set to ensure the email is associated with the correct user profile. If identify is not called, Mixpanel will queue the profile update until the user is identified.

Did this answer your question?