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';
23
23
// import { FacebookAppEventsPlugin } from '@segment/analytics-react-native-plugin-facebook-app-events';
24
24
25
25
// @ts -ignore
26
- // import { IdfaPlugin } from '@segment/analytics-react-native-plugin-idfa';
26
+ import { IdfaPlugin } from '@segment/analytics-react-native-plugin-idfa' ;
27
27
// @ts -ignore
28
28
import { AmplitudeSessionPlugin } from '@segment/analytics-react-native-plugin-amplitude-session' ;
29
29
@@ -43,7 +43,7 @@ segmentClient.add({ plugin: LoggerPlugin });
43
43
// To test the Facebook App Events plugin make sure to add your Facebook App Id to Info.plist
44
44
// segmentClient.add({ plugin: new FacebookAppEventsPlugin() });
45
45
46
- // segmentClient.add({ plugin: new IdfaPlugin() });
46
+ segmentClient . add ( { plugin : new IdfaPlugin ( ) } ) ;
47
47
segmentClient . add ( { plugin : new AmplitudeSessionPlugin ( ) } ) ;
48
48
49
49
const MainStack = createStackNavigator ( ) ;
Original file line number Diff line number Diff line change 1
1
/**
2
2
* This module is just here to have a way to mock the Native Module of IDFA with Detox
3
3
*/
4
- import { NativeModules } from 'react-native' ;
4
+ import { NativeModules , Platform } from 'react-native' ;
5
5
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 {
23
23
}
24
24
25
25
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
+ } ) ;
30
34
}
31
35
}
You can’t perform that action at this time.
0 commit comments