Skip to content

RudderStack's Facebook Native SDK integration support. RudderStack is an open-source, warehouse-first Customer Data Pipeline and Segment-alternative. It collects and routes clickstream data and builds your customer data lake on your data warehouse.

License

Notifications You must be signed in to change notification settings

rudderlabs/rudder-integration-facebook-ios

Repository files navigation

What is RudderStack?

RudderStack is a customer data pipeline tool for collecting, routing and processing data from your websites, apps, cloud tools, and data warehouse.

More information on RudderStack can be found here.

Integrating Facebook with RudderStack's iOS SDK

  1. Add Facebook as a destination in the Dashboard.

  2. Rudder-Facebook is available through CocoaPods. To install it, add the following line to your Podfile and followed by pod install:

pod 'Rudder-Facebook'

Initialize RSClient

Put the following code in your AppDelegate.m file under the method didFinishLaunchingWithOptions:

RSConfigBuilder *builder = [[RSConfigBuilder alloc] init];
[builder withDataPlaneUrl:DATA_PLANE_URL];
[builder withFactory:[RudderFacebookFactory instance]];
[RSClient getInstance:WRITE_KEY config:[builder build]];
  1. To enable the sending of events to Facebook App Events on iOS 14+ app MUST request user for tracking:

Put the following snippet in your AppDelegate.m file under the method didFinishLaunchingWithOptions:

NSTimeInterval delayInSeconds = 1.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    [self requestTracking];
    });

Then put the below snippet in your AppDelegate.m file

-(void) requestTracking {
    if (@available(iOS 14, *)) {
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
            switch (status){
                case ATTrackingManagerAuthorizationStatusNotDetermined:
                    break;
                case ATTrackingManagerAuthorizationStatusRestricted:
                    break;
                case ATTrackingManagerAuthorizationStatusAuthorized:
                    [FBSDKSettings.sharedSettings setAutoLogAppEventsEnabled:true];
                    [FBSDKSettings.sharedSettings setAdvertiserTrackingEnabled:true];
                    [FBSDKSettings.sharedSettings setAdvertiserIDCollectionEnabled:true];
                    break;
            case ATTrackingManagerAuthorizationStatusDenied:
                    [FBSDKSettings.sharedSettings setAutoLogAppEventsEnabled:false];
                    [FBSDKSettings.sharedSettings setAdvertiserTrackingEnabled:false];
                    [FBSDKSettings.sharedSettings setAdvertiserIDCollectionEnabled:false];
                    break;
            default:
                    break;
            }
        }];
    }
}

Send Events

Follow the steps from the RudderStack iOS SDK.

Contact Us

If you come across any issues while configuring or using this integration, please feel free to [start a conversation on our Slack channel. We will be happy to help you.

About

RudderStack's Facebook Native SDK integration support. RudderStack is an open-source, warehouse-first Customer Data Pipeline and Segment-alternative. It collects and routes clickstream data and builds your customer data lake on your data warehouse.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published