This repository was archived by the owner on Jun 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-8
lines changed
packages/plugins/plugin-idfa/src Expand file tree Collapse file tree 3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ import { Logger } from './plugins/Logger';
2323// import { FacebookAppEventsPlugin } from '@segment/analytics-react-native-plugin-facebook-app-events';
2424
2525// @ts -ignore
26- // import { IdfaPlugin } from '@segment/analytics-react-native-plugin-idfa';
26+ import { IdfaPlugin } from '@segment/analytics-react-native-plugin-idfa' ;
2727// @ts -ignore
2828import { AmplitudeSessionPlugin } from '@segment/analytics-react-native-plugin-amplitude-session' ;
2929
@@ -43,7 +43,7 @@ segmentClient.add({ plugin: LoggerPlugin });
4343// To test the Facebook App Events plugin make sure to add your Facebook App Id to Info.plist
4444// segmentClient.add({ plugin: new FacebookAppEventsPlugin() });
4545
46- // segmentClient.add({ plugin: new IdfaPlugin() });
46+ segmentClient . add ( { plugin : new IdfaPlugin ( ) } ) ;
4747segmentClient . add ( { plugin : new AmplitudeSessionPlugin ( ) } ) ;
4848
4949const MainStack = createStackNavigator ( ) ;
Original file line number Diff line number Diff line change 11/**
22 * This module is just here to have a way to mock the Native Module of IDFA with Detox
33 */
4- import { NativeModules } from 'react-native' ;
4+ import { NativeModules , Platform } from 'react-native' ;
55
6- export const { AnalyticsReactNativePluginIdfa } = NativeModules ;
6+ export const AnalyticsReactNativePluginIdfa = Platform . select ( {
7+ default : {
8+ getTrackingAuthorizationStatus : ( ) => {
9+ return Promise . reject ( 'IDFA is only supported on iOS' ) ;
10+ } ,
11+ } ,
12+ ios : NativeModules . AnalyticsReactNativePluginIdfa ,
13+ } ) ;
Original file line number Diff line number Diff line change @@ -23,9 +23,13 @@ export class IdfaPlugin extends Plugin {
2323 }
2424
2525 getTrackingStatus ( ) {
26- getTrackingAuthorizationStatus ( ) . then ( ( idfa : IdfaData ) => {
27- // update our context with the idfa data
28- this . analytics ?. context . set ( { device : { ...idfa } } ) ;
29- } ) ;
26+ getTrackingAuthorizationStatus ( )
27+ . then ( ( idfa : IdfaData ) => {
28+ // update our context with the idfa data
29+ this . analytics ?. context . set ( { device : { ...idfa } } ) ;
30+ } )
31+ . catch ( ( err : any ) => {
32+ console . warn ( err ) ;
33+ } ) ;
3034 }
3135}
You can’t perform that action at this time.
0 commit comments