ios-branch-deep-linking-attribution
ios-branch-deep-linking-attribution copied to clipboard
Adding Segment to Branch: error: use of undeclared identifier 'SEGAnalytics'
I am getting the following error trying to add Segment tracking to Branch, via the following guide: https://help.branch.io/using-branch/page/segment-export#pass-segment-anonymous-id
The code I added was the following:
[[RNBranch getInstance] setRequestMetadataKey:@"$segment_anonymous_id" value:[[SEGAnalytics sharedAnalytics] getAnonymousId]];
And the error that I am getting is the following:
consumer-mobile/ios/Alle/AppDelegate.m:62:14: error: no known class method for selector 'getInstance'
[[RNBranch getInstance] setRequestMetadataKey:@"$segment_anonymous_id" value:[[SEGAnalytics sharedAnalytics] getAnonymousId]];
^~~~~~~~~~~
consumer-mobile/ios/Alle/AppDelegate.m:62:82: error: use of undeclared identifier 'SEGAnalytics'
[[RNBranch getInstance] setRequestMetadataKey:@"$segment_anonymous_id" value:[[SEGAnalytics sharedAnalytics] getAnonymousId]];
I think I need to add SEGAnalytics to the repo but the tutorial isn't clear to me on how thats done, we already use segment analytics in the app (which is React-Native) so I am confused whether this would be a re-implementation, a different implementation, or something thats not necessary. Any clarity on this would be very helpful!
Version: "react-native-branch": "5.0.3"
Hey @simistern
To address your first error, you shouldn't have to call getInstance for the RN module on the native iOS layer. Therefore [RNBranch setRequestMetadataKey:@"$segment_anonymous_id" value:[[SEGAnalytics sharedAnalytics] getAnonymousId]] will do.
The second error entails access to the Segment library at the native layer which I strongly suggest inquiring with your Segment representative or the Segment Support Team. With that said, it seems you can enable native configuration through:
import analytics from '@segment/analytics-react-native';
analytics.useNativeConfiguration();
Which may require you to migrate your Segment setup/initialization to the native layers as well. SO thread