Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

feature: implement initialize sdk #841

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@ public void setDataProcessingOptions(@Nullable String[] options) {
public static void setDataProcessingOptionsExtra(@Nullable String[] options, int country, int state) {
FacebookSdk.setDataProcessingOptions(options, country, state);
}

/**
* Initialize the sdk
* [FB SDK Best Practices for GDPR Compliance](https://developers.facebook.com/docs/app-events/gdpr-compliance/)
*/
@ReactMethod
public static void initializeSDK() {
FacebookSdk.fullyInitialize();
}
}
11 changes: 10 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
* @format
*/

import {AppRegistry} from 'react-native';
import {AppRegistry, Platform} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';
import {Settings} from 'react-native-fbsdk';

/**
* The `autoInitEnabled` option is removed from facebook-ios-sdk, should initialize manually
* See https://github.com/facebook/facebook-ios-sdk/blob/master/CHANGELOG.md#removed
*/
if(Platform.OS === 'ios'){
Settings.initializeSDK();
}

AppRegistry.registerComponent(appName, () => App);
5 changes: 5 additions & 0 deletions ios/RCTFBSDK/core/RCTFBSDKSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ - (dispatch_queue_t)methodQueue
[FBSDKSettings setDataProcessingOptions:options country:country state:state];
}

RCT_EXPORT_METHOD(initializeSDK)
{
[FBSDKApplicationDelegate initializeSDK:nil];
}

@end
6 changes: 6 additions & 0 deletions src/FBSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ module.exports = {
}
Settings.setDataProcessingOptions(options, country, state);
},
/**
* Initialize the sdk
*/
initializeSDK() {
Settings.initializeSDK();
},
};