@ohos-ports/react-native-fbsdk-next 13.4.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +943 -0
- package/android/build.gradle +57 -0
- package/android/src/main/AndroidManifest.xml +46 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBAccessTokenModule.java +151 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBActivityEventListener.java +40 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBAppEventsLoggerModule.java +414 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBAppLinkModule.java +86 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBGameRequestDialogModule.java +94 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBGraphRequestModule.java +283 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBLoginButtonManager.java +83 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBLoginManagerModule.java +171 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBMessageDialogModule.java +111 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBProfileModule.java +68 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKCallbackManagerBaseJavaModule.java +41 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKPackage.java +60 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBSendButtonManager.java +51 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBSettingsModule.java +95 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBShareButtonManager.java +53 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/FBShareDialogModule.java +107 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/RCTLoginButton.java +126 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/RCTLoginButtonEvent.java +27 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/ReactNativeFacebookSDKCallback.java +58 -0
- package/android/src/main/java/com/facebook/reactnative/androidsdk/Utility.java +283 -0
- package/app.plugin.js +1 -0
- package/expo-module.config.json +10 -0
- package/ios/ExpoAdapterFBSDKNext/FacebookAppDelegate.swift +21 -0
- package/ios/ExpoAdapterFBSDKNext.podspec +33 -0
- package/ios/RCTFBSDK/core/RCTConvert+FBSDKAccessToken.h +27 -0
- package/ios/RCTFBSDK/core/RCTConvert+FBSDKAccessToken.m +41 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAEMReporter.m +30 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAccessToken.h +24 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAccessToken.m +115 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAppEvents.h +24 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAppEvents.m +251 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAppLink.h +24 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAppLink.m +52 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAuthenticationToken.h +6 -0
- package/ios/RCTFBSDK/core/RCTFBSDKAuthenticationToken.m +35 -0
- package/ios/RCTFBSDK/core/RCTFBSDKGraphRequestConnectionContainer.h +50 -0
- package/ios/RCTFBSDK/core/RCTFBSDKGraphRequestConnectionContainer.m +124 -0
- package/ios/RCTFBSDK/core/RCTFBSDKGraphRequestManager.h +25 -0
- package/ios/RCTFBSDK/core/RCTFBSDKGraphRequestManager.m +43 -0
- package/ios/RCTFBSDK/core/RCTFBSDKProfile.h +6 -0
- package/ios/RCTFBSDK/core/RCTFBSDKProfile.m +58 -0
- package/ios/RCTFBSDK/core/RCTFBSDKSettings.h +14 -0
- package/ios/RCTFBSDK/core/RCTFBSDKSettings.m +80 -0
- package/ios/RCTFBSDK/login/RCTConvert+FBSDKLogin.h +28 -0
- package/ios/RCTFBSDK/login/RCTConvert+FBSDKLogin.m +35 -0
- package/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.h +25 -0
- package/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m +73 -0
- package/ios/RCTFBSDK/login/RCTFBSDKLoginButtonView.h +12 -0
- package/ios/RCTFBSDK/login/RCTFBSDKLoginButtonView.m +57 -0
- package/ios/RCTFBSDK/login/RCTFBSDKLoginManager.h +22 -0
- package/ios/RCTFBSDK/login/RCTFBSDKLoginManager.m +154 -0
- package/ios/RCTFBSDK/share/RCTConvert+FBSDKSharingContent.h +29 -0
- package/ios/RCTFBSDK/share/RCTConvert+FBSDKSharingContent.m +111 -0
- package/ios/RCTFBSDK/share/RCTFBSDKGameRequestDialog.h +24 -0
- package/ios/RCTFBSDK/share/RCTFBSDKGameRequestDialog.m +134 -0
- package/ios/RCTFBSDK/share/RCTFBSDKMessageDialog.h +24 -0
- package/ios/RCTFBSDK/share/RCTFBSDKMessageDialog.m +116 -0
- package/ios/RCTFBSDK/share/RCTFBSDKSendButtonManager.h +25 -0
- package/ios/RCTFBSDK/share/RCTFBSDKSendButtonManager.m +39 -0
- package/ios/RCTFBSDK/share/RCTFBSDKShareButtonManager.h +23 -0
- package/ios/RCTFBSDK/share/RCTFBSDKShareButtonManager.m +39 -0
- package/ios/RCTFBSDK/share/RCTFBSDKShareDialog.h +24 -0
- package/ios/RCTFBSDK/share/RCTFBSDKShareDialog.m +134 -0
- package/ios/RCTFBSDK/share/RCTFBSDKShareHelper.h +21 -0
- package/ios/RCTFBSDK/share/RCTFBSDKShareHelper.m +32 -0
- package/ios/RCTFBSDK.xcodeproj/project.pbxproj +446 -0
- package/ios/RCTFBSDK.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/RCTFBSDK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/jest/mocks/index.js +81 -0
- package/jest/setup.js +3 -0
- package/lib/commonjs/FBAEMReporter.js +39 -0
- package/lib/commonjs/FBAEMReporter.js.map +1 -0
- package/lib/commonjs/FBAccessToken.js +198 -0
- package/lib/commonjs/FBAccessToken.js.map +1 -0
- package/lib/commonjs/FBAppEventsLogger.js +221 -0
- package/lib/commonjs/FBAppEventsLogger.js.map +1 -0
- package/lib/commonjs/FBAppLink.js +36 -0
- package/lib/commonjs/FBAppLink.js.map +1 -0
- package/lib/commonjs/FBAuthenticationToken.js +55 -0
- package/lib/commonjs/FBAuthenticationToken.js.map +1 -0
- package/lib/commonjs/FBGameRequestDialog.js +45 -0
- package/lib/commonjs/FBGameRequestDialog.js.map +1 -0
- package/lib/commonjs/FBGraphRequest.js +66 -0
- package/lib/commonjs/FBGraphRequest.js.map +1 -0
- package/lib/commonjs/FBGraphRequestManager.js +96 -0
- package/lib/commonjs/FBGraphRequestManager.js.map +1 -0
- package/lib/commonjs/FBLoginButton.js +67 -0
- package/lib/commonjs/FBLoginButton.js.map +1 -0
- package/lib/commonjs/FBLoginManager.js +102 -0
- package/lib/commonjs/FBLoginManager.js.map +1 -0
- package/lib/commonjs/FBMessageDialog.js +51 -0
- package/lib/commonjs/FBMessageDialog.js.map +1 -0
- package/lib/commonjs/FBProfile.js +134 -0
- package/lib/commonjs/FBProfile.js.map +1 -0
- package/lib/commonjs/FBSendButton.js +48 -0
- package/lib/commonjs/FBSendButton.js.map +1 -0
- package/lib/commonjs/FBSettings.js +115 -0
- package/lib/commonjs/FBSettings.js.map +1 -0
- package/lib/commonjs/FBShareButton.js +48 -0
- package/lib/commonjs/FBShareButton.js.map +1 -0
- package/lib/commonjs/FBShareDialog.js +57 -0
- package/lib/commonjs/FBShareDialog.js.map +1 -0
- package/lib/commonjs/index.js +323 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/models/FBAppGroupCreationContent.js +2 -0
- package/lib/commonjs/models/FBAppGroupCreationContent.js.map +1 -0
- package/lib/commonjs/models/FBGameRequestContent.js +2 -0
- package/lib/commonjs/models/FBGameRequestContent.js.map +1 -0
- package/lib/commonjs/models/FBSDKCallback.js +2 -0
- package/lib/commonjs/models/FBSDKCallback.js.map +1 -0
- package/lib/commonjs/models/FBShareContent.js +6 -0
- package/lib/commonjs/models/FBShareContent.js.map +1 -0
- package/lib/commonjs/models/FBShareLinkContent.js +6 -0
- package/lib/commonjs/models/FBShareLinkContent.js.map +1 -0
- package/lib/commonjs/models/FBSharePhoto.js +2 -0
- package/lib/commonjs/models/FBSharePhoto.js.map +1 -0
- package/lib/commonjs/models/FBSharePhotoContent.js +6 -0
- package/lib/commonjs/models/FBSharePhotoContent.js.map +1 -0
- package/lib/commonjs/models/FBShareVideo.js +2 -0
- package/lib/commonjs/models/FBShareVideo.js.map +1 -0
- package/lib/commonjs/models/FBShareVideoContent.js +6 -0
- package/lib/commonjs/models/FBShareVideoContent.js.map +1 -0
- package/lib/commonjs/util/validate.js +180 -0
- package/lib/commonjs/util/validate.js.map +1 -0
- package/lib/commonjs/utils/index.js +2 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/FBAEMReporter.js +34 -0
- package/lib/module/FBAEMReporter.js.map +1 -0
- package/lib/module/FBAccessToken.js +191 -0
- package/lib/module/FBAccessToken.js.map +1 -0
- package/lib/module/FBAppEventsLogger.js +215 -0
- package/lib/module/FBAppEventsLogger.js.map +1 -0
- package/lib/module/FBAppLink.js +29 -0
- package/lib/module/FBAppLink.js.map +1 -0
- package/lib/module/FBAuthenticationToken.js +48 -0
- package/lib/module/FBAuthenticationToken.js.map +1 -0
- package/lib/module/FBGameRequestDialog.js +39 -0
- package/lib/module/FBGameRequestDialog.js.map +1 -0
- package/lib/module/FBGraphRequest.js +60 -0
- package/lib/module/FBGraphRequest.js.map +1 -0
- package/lib/module/FBGraphRequestManager.js +90 -0
- package/lib/module/FBGraphRequestManager.js.map +1 -0
- package/lib/module/FBLoginButton.js +62 -0
- package/lib/module/FBLoginButton.js.map +1 -0
- package/lib/module/FBLoginManager.js +97 -0
- package/lib/module/FBLoginManager.js.map +1 -0
- package/lib/module/FBMessageDialog.js +45 -0
- package/lib/module/FBMessageDialog.js.map +1 -0
- package/lib/module/FBProfile.js +127 -0
- package/lib/module/FBProfile.js.map +1 -0
- package/lib/module/FBSendButton.js +41 -0
- package/lib/module/FBSendButton.js.map +1 -0
- package/lib/module/FBSettings.js +108 -0
- package/lib/module/FBSettings.js.map +1 -0
- package/lib/module/FBShareButton.js +41 -0
- package/lib/module/FBShareButton.js.map +1 -0
- package/lib/module/FBShareDialog.js +51 -0
- package/lib/module/FBShareDialog.js.map +1 -0
- package/lib/module/index.js +44 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/FBAppGroupCreationContent.js +2 -0
- package/lib/module/models/FBAppGroupCreationContent.js.map +1 -0
- package/lib/module/models/FBGameRequestContent.js +2 -0
- package/lib/module/models/FBGameRequestContent.js.map +1 -0
- package/lib/module/models/FBSDKCallback.js +2 -0
- package/lib/module/models/FBSDKCallback.js.map +1 -0
- package/lib/module/models/FBShareContent.js +2 -0
- package/lib/module/models/FBShareContent.js.map +1 -0
- package/lib/module/models/FBShareLinkContent.js +2 -0
- package/lib/module/models/FBShareLinkContent.js.map +1 -0
- package/lib/module/models/FBSharePhoto.js +2 -0
- package/lib/module/models/FBSharePhoto.js.map +1 -0
- package/lib/module/models/FBSharePhotoContent.js +2 -0
- package/lib/module/models/FBSharePhotoContent.js.map +1 -0
- package/lib/module/models/FBShareVideo.js +2 -0
- package/lib/module/models/FBShareVideo.js.map +1 -0
- package/lib/module/models/FBShareVideoContent.js +2 -0
- package/lib/module/models/FBShareVideoContent.js.map +1 -0
- package/lib/module/util/validate.js +157 -0
- package/lib/module/util/validate.js.map +1 -0
- package/lib/module/utils/index.js +2 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/FBAEMReporter.d.ts +21 -0
- package/lib/typescript/FBAEMReporter.d.ts.map +1 -0
- package/lib/typescript/FBAccessToken.d.ts +118 -0
- package/lib/typescript/FBAccessToken.d.ts.map +1 -0
- package/lib/typescript/FBAppEventsLogger.d.ts +201 -0
- package/lib/typescript/FBAppEventsLogger.d.ts.map +1 -0
- package/lib/typescript/FBAppLink.d.ts +5 -0
- package/lib/typescript/FBAppLink.d.ts.map +1 -0
- package/lib/typescript/FBAuthenticationToken.d.ts +29 -0
- package/lib/typescript/FBAuthenticationToken.d.ts.map +1 -0
- package/lib/typescript/FBGameRequestDialog.d.ts +39 -0
- package/lib/typescript/FBGameRequestDialog.d.ts.map +1 -0
- package/lib/typescript/FBGraphRequest.d.ts +70 -0
- package/lib/typescript/FBGraphRequest.d.ts.map +1 -0
- package/lib/typescript/FBGraphRequestManager.d.ts +51 -0
- package/lib/typescript/FBGraphRequestManager.d.ts.map +1 -0
- package/lib/typescript/FBLoginButton.d.ts +92 -0
- package/lib/typescript/FBLoginButton.d.ts.map +1 -0
- package/lib/typescript/FBLoginManager.d.ts +77 -0
- package/lib/typescript/FBLoginManager.d.ts.map +1 -0
- package/lib/typescript/FBMessageDialog.d.ts +42 -0
- package/lib/typescript/FBMessageDialog.d.ts.map +1 -0
- package/lib/typescript/FBProfile.d.ts +127 -0
- package/lib/typescript/FBProfile.d.ts.map +1 -0
- package/lib/typescript/FBSendButton.d.ts +42 -0
- package/lib/typescript/FBSendButton.d.ts.map +1 -0
- package/lib/typescript/FBSettings.d.ts +49 -0
- package/lib/typescript/FBSettings.d.ts.map +1 -0
- package/lib/typescript/FBShareButton.d.ts +42 -0
- package/lib/typescript/FBShareButton.d.ts.map +1 -0
- package/lib/typescript/FBShareDialog.d.ts +69 -0
- package/lib/typescript/FBShareDialog.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +43 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/models/FBAppGroupCreationContent.d.ts +43 -0
- package/lib/typescript/models/FBAppGroupCreationContent.d.ts.map +1 -0
- package/lib/typescript/models/FBGameRequestContent.d.ts +63 -0
- package/lib/typescript/models/FBGameRequestContent.d.ts.map +1 -0
- package/lib/typescript/models/FBSDKCallback.d.ts +4 -0
- package/lib/typescript/models/FBSDKCallback.d.ts.map +1 -0
- package/lib/typescript/models/FBShareContent.d.ts +48 -0
- package/lib/typescript/models/FBShareContent.d.ts.map +1 -0
- package/lib/typescript/models/FBShareLinkContent.d.ts +65 -0
- package/lib/typescript/models/FBShareLinkContent.d.ts.map +1 -0
- package/lib/typescript/models/FBSharePhoto.d.ts +43 -0
- package/lib/typescript/models/FBSharePhoto.d.ts.map +1 -0
- package/lib/typescript/models/FBSharePhotoContent.d.ts +45 -0
- package/lib/typescript/models/FBSharePhotoContent.d.ts.map +1 -0
- package/lib/typescript/models/FBShareVideo.d.ts +31 -0
- package/lib/typescript/models/FBShareVideo.d.ts.map +1 -0
- package/lib/typescript/models/FBShareVideoContent.d.ts +58 -0
- package/lib/typescript/models/FBShareVideoContent.d.ts.map +1 -0
- package/lib/typescript/util/validate.d.ts +62 -0
- package/lib/typescript/util/validate.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +2 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/package.json +155 -0
- package/plugin/build/config.d.ts +53 -0
- package/plugin/build/config.js +46 -0
- package/plugin/build/withFacebook.d.ts +4 -0
- package/plugin/build/withFacebook.js +59 -0
- package/plugin/build/withFacebookAndroid.d.ts +6 -0
- package/plugin/build/withFacebookAndroid.js +197 -0
- package/plugin/build/withFacebookIOS.d.ts +15 -0
- package/plugin/build/withFacebookIOS.js +163 -0
- package/plugin/build/withSKAdNetworkIdentifiers.d.ts +9 -0
- package/plugin/build/withSKAdNetworkIdentifiers.js +36 -0
- package/plugin/tsconfig.json +9 -0
- package/react-native-fbsdk-next.podspec +34 -0
- package/src/FBAEMReporter.ts +44 -0
- package/src/FBAccessToken.ts +222 -0
- package/src/FBAppEventsLogger.ts +375 -0
- package/src/FBAppLink.ts +30 -0
- package/src/FBAuthenticationToken.ts +61 -0
- package/src/FBGameRequestDialog.ts +49 -0
- package/src/FBGraphRequest.ts +89 -0
- package/src/FBGraphRequestManager.ts +117 -0
- package/src/FBLoginButton.tsx +152 -0
- package/src/FBLoginManager.ts +133 -0
- package/src/FBMessageDialog.ts +53 -0
- package/src/FBProfile.ts +166 -0
- package/src/FBSendButton.tsx +61 -0
- package/src/FBSettings.ts +122 -0
- package/src/FBShareButton.tsx +61 -0
- package/src/FBShareDialog.ts +96 -0
- package/src/index.ts +85 -0
- package/src/models/FBAppGroupCreationContent.ts +48 -0
- package/src/models/FBGameRequestContent.ts +81 -0
- package/src/models/FBSDKCallback.ts +3 -0
- package/src/models/FBShareContent.ts +54 -0
- package/src/models/FBShareLinkContent.ts +71 -0
- package/src/models/FBSharePhoto.ts +45 -0
- package/src/models/FBSharePhotoContent.ts +48 -0
- package/src/models/FBShareVideo.ts +31 -0
- package/src/models/FBShareVideoContent.ts +64 -0
- package/src/util/validate.ts +167 -0
- package/src/utils/index.ts +1 -0
- package/tsconfig.json +103 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#import "RCTFBSDKProfile.h"
|
|
2
|
+
#import <React/RCTLog.h>
|
|
3
|
+
|
|
4
|
+
#import <React/RCTUtils.h>
|
|
5
|
+
|
|
6
|
+
@implementation RCTFBSDKProfile
|
|
7
|
+
|
|
8
|
+
RCT_EXPORT_MODULE(FBProfile);
|
|
9
|
+
|
|
10
|
+
- (dispatch_queue_t)methodQueue
|
|
11
|
+
{
|
|
12
|
+
return dispatch_get_main_queue();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
RCT_EXPORT_METHOD(getCurrentProfile:(RCTResponseSenderBlock)callback)
|
|
16
|
+
{
|
|
17
|
+
NSDictionary *profileDict = RCTBuildProfileDict();
|
|
18
|
+
callback(@[RCTNullIfNil(profileDict)]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#pragma mark - Helper Functions
|
|
22
|
+
|
|
23
|
+
static NSDictionary *RCTBuildProfileDict(void)
|
|
24
|
+
{
|
|
25
|
+
if (!FBSDKProfile.currentProfile) {
|
|
26
|
+
return nil;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return @{
|
|
30
|
+
@"name": FBSDKProfile.currentProfile.name ? FBSDKProfile.currentProfile.name : [NSNull null],
|
|
31
|
+
@"firstName": FBSDKProfile.currentProfile.firstName ? FBSDKProfile.currentProfile.firstName : [NSNull null],
|
|
32
|
+
@"lastName": FBSDKProfile.currentProfile.lastName ? FBSDKProfile.currentProfile.lastName : [NSNull null],
|
|
33
|
+
@"middleName": FBSDKProfile.currentProfile.middleName ? FBSDKProfile.currentProfile.middleName : [NSNull null],
|
|
34
|
+
@"imageURL": FBSDKProfile.currentProfile.imageURL ? FBSDKProfile.currentProfile.imageURL.relativeString : [NSNull null],
|
|
35
|
+
@"linkURL": FBSDKProfile.currentProfile.linkURL ? FBSDKProfile.currentProfile.linkURL.relativeString : [NSNull null],
|
|
36
|
+
@"userID": FBSDKProfile.currentProfile.userID ? FBSDKProfile.currentProfile.userID : [NSNull null],
|
|
37
|
+
@"email": FBSDKProfile.currentProfile.email ? FBSDKProfile.currentProfile.email : [NSNull null],
|
|
38
|
+
@"refreshDate": FBSDKProfile.currentProfile.refreshDate ? @(FBSDKProfile.currentProfile.refreshDate.timeIntervalSince1970 * 1000) : [NSNull null],
|
|
39
|
+
@"friendIDs": FBSDKProfile.currentProfile.friendIDs ? FBSDKProfile.currentProfile.friendIDs : [NSNull null],
|
|
40
|
+
@"birthday": FBSDKProfile.currentProfile.birthday ? @(FBSDKProfile.currentProfile.birthday.timeIntervalSince1970 * 1000) : [NSNull null],
|
|
41
|
+
@"ageRange": FBSDKProfile.currentProfile.ageRange ? @{
|
|
42
|
+
@"min": FBSDKProfile.currentProfile.ageRange.min,
|
|
43
|
+
@"max": FBSDKProfile.currentProfile.ageRange.max
|
|
44
|
+
} : [NSNull null],
|
|
45
|
+
@"hometown": FBSDKProfile.currentProfile.hometown ? @{
|
|
46
|
+
@"id": FBSDKProfile.currentProfile.hometown.id,
|
|
47
|
+
@"name": FBSDKProfile.currentProfile.hometown.name
|
|
48
|
+
} : [NSNull null],
|
|
49
|
+
@"location": FBSDKProfile.currentProfile.location ? @{
|
|
50
|
+
@"id": FBSDKProfile.currentProfile.location.id,
|
|
51
|
+
@"name": FBSDKProfile.currentProfile.location.name
|
|
52
|
+
} : [NSNull null],
|
|
53
|
+
@"gender": FBSDKProfile.currentProfile.gender ? FBSDKProfile.currentProfile.gender : [NSNull null],
|
|
54
|
+
@"permissions": FBSDKProfile.currentProfile.permissions ? FBSDKProfile.currentProfile.permissions.allObjects : [NSNull null]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#import <React/RCTBridgeModule.h>
|
|
10
|
+
|
|
11
|
+
#import <FBSDKCoreKit/FBSDKCoreKit.h>
|
|
12
|
+
|
|
13
|
+
@interface RCTFBSDKSettings : NSObject <RCTBridgeModule>
|
|
14
|
+
@end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#import "RCTFBSDKSettings.h"
|
|
10
|
+
|
|
11
|
+
#import <React/RCTConvert.h>
|
|
12
|
+
|
|
13
|
+
@implementation RCTFBSDKSettings
|
|
14
|
+
|
|
15
|
+
RCT_EXPORT_MODULE(FBSettings);
|
|
16
|
+
|
|
17
|
+
- (dispatch_queue_t)methodQueue
|
|
18
|
+
{
|
|
19
|
+
return dispatch_get_main_queue();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#pragma mark - React Native Methods
|
|
23
|
+
|
|
24
|
+
RCT_EXPORT_METHOD(getAdvertiserTrackingEnabled:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject)
|
|
25
|
+
{
|
|
26
|
+
BOOL ATE = FBSDKSettings.sharedSettings.isAdvertiserTrackingEnabled;
|
|
27
|
+
resolve(@(ATE));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
RCT_EXPORT_METHOD(setAdvertiserTrackingEnabled:(BOOL)ATE resolver:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject)
|
|
31
|
+
{
|
|
32
|
+
[FBSDKSettings.sharedSettings setIsAdvertiserTrackingEnabled:ATE];
|
|
33
|
+
resolve(@(true)); // true means successfully changed
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
RCT_EXPORT_METHOD(setDataProcessingOptions:(nullable NSArray<NSString *> *)options)
|
|
37
|
+
{
|
|
38
|
+
[FBSDKSettings.sharedSettings setDataProcessingOptions:options];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
RCT_EXPORT_METHOD(setDataProcessingOptions:(nullable NSArray<NSString *> *)options country:(int)country state:(int)state)
|
|
42
|
+
{
|
|
43
|
+
[FBSDKSettings.sharedSettings setDataProcessingOptions:options country:country state:state];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
RCT_EXPORT_METHOD(initializeSDK)
|
|
47
|
+
{
|
|
48
|
+
[FBSDKApplicationDelegate.sharedInstance initializeSDK];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
RCT_EXPORT_METHOD(setAppID:(NSString *)appID)
|
|
52
|
+
{
|
|
53
|
+
[FBSDKSettings.sharedSettings setAppID:appID];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
RCT_EXPORT_METHOD(setClientToken:(NSString *)clientToken)
|
|
57
|
+
{
|
|
58
|
+
[FBSDKSettings.sharedSettings setClientToken:clientToken];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
RCT_EXPORT_METHOD(setAppName:(NSString *)displayName)
|
|
62
|
+
{
|
|
63
|
+
[FBSDKSettings.sharedSettings setDisplayName:displayName];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
RCT_EXPORT_METHOD(setGraphAPIVersion:(NSString *)version)
|
|
67
|
+
{
|
|
68
|
+
[FBSDKSettings.sharedSettings setGraphAPIVersion:version];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
RCT_EXPORT_METHOD(setAutoLogAppEventsEnabled:(BOOL)enabled)
|
|
72
|
+
{
|
|
73
|
+
[FBSDKSettings.sharedSettings setIsAutoLogAppEventsEnabled:enabled];
|
|
74
|
+
}
|
|
75
|
+
RCT_EXPORT_METHOD(setAdvertiserIDCollectionEnabled:(BOOL)enabled resolver:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject)
|
|
76
|
+
{
|
|
77
|
+
[FBSDKSettings.sharedSettings setIsAdvertiserIDCollectionEnabled:enabled];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
4
|
+
// copy, modify, and distribute this software in source code or binary form for use
|
|
5
|
+
// in connection with the web services and APIs provided by Facebook.
|
|
6
|
+
//
|
|
7
|
+
// As with any software that integrates with the Facebook platform, your use of
|
|
8
|
+
// this software is subject to the Facebook Developer Principles and Policies
|
|
9
|
+
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
10
|
+
// included in all copies or substantial portions of the software.
|
|
11
|
+
//
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
14
|
+
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
16
|
+
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
17
|
+
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
#import <React/RCTConvert.h>
|
|
20
|
+
|
|
21
|
+
#import <FBSDKLoginKit/FBSDKLoginKit.h>
|
|
22
|
+
|
|
23
|
+
@interface RCTConvert (FBSDKLogin)
|
|
24
|
+
|
|
25
|
+
+ (FBSDKDefaultAudience)FBSDKDefaultAudience:(id)json;
|
|
26
|
+
+ (FBSDKLoginButtonTooltipBehavior)FBSDKLoginButtonTooltipBehavior:(id)json;
|
|
27
|
+
|
|
28
|
+
@end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
4
|
+
// copy, modify, and distribute this software in source code or binary form for use
|
|
5
|
+
// in connection with the web services and APIs provided by Facebook.
|
|
6
|
+
//
|
|
7
|
+
// As with any software that integrates with the Facebook platform, your use of
|
|
8
|
+
// this software is subject to the Facebook Developer Principles and Policies
|
|
9
|
+
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
10
|
+
// included in all copies or substantial portions of the software.
|
|
11
|
+
//
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
14
|
+
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
16
|
+
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
17
|
+
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
#import "RCTConvert+FBSDKLogin.h"
|
|
20
|
+
|
|
21
|
+
@implementation RCTConvert(FBSDKLogin)
|
|
22
|
+
|
|
23
|
+
RCT_ENUM_CONVERTER(FBSDKDefaultAudience, (@{
|
|
24
|
+
@"friends": @(FBSDKDefaultAudienceFriends),
|
|
25
|
+
@"everyone": @(FBSDKDefaultAudienceEveryone),
|
|
26
|
+
@"only_me": @(FBSDKDefaultAudienceOnlyMe),
|
|
27
|
+
}), FBSDKDefaultAudienceFriends, unsignedLongValue)
|
|
28
|
+
|
|
29
|
+
RCT_ENUM_CONVERTER(FBSDKLoginButtonTooltipBehavior, (@{
|
|
30
|
+
@"auto": @(FBSDKLoginButtonTooltipBehaviorAutomatic),
|
|
31
|
+
@"force_display": @(FBSDKLoginButtonTooltipBehaviorForceDisplay),
|
|
32
|
+
@"disable": @(FBSDKLoginButtonTooltipBehaviorDisable),
|
|
33
|
+
}), FBSDKLoginButtonTooltipBehaviorAutomatic, unsignedIntegerValue)
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
4
|
+
// copy, modify, and distribute this software in source code or binary form for use
|
|
5
|
+
// in connection with the web services and APIs provided by Facebook.
|
|
6
|
+
//
|
|
7
|
+
// As with any software that integrates with the Facebook platform, your use of
|
|
8
|
+
// this software is subject to the Facebook Developer Principles and Policies
|
|
9
|
+
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
10
|
+
// included in all copies or substantial portions of the software.
|
|
11
|
+
//
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
14
|
+
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
16
|
+
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
17
|
+
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
#import <FBSDKLoginKit/FBSDKLoginKit.h>
|
|
20
|
+
|
|
21
|
+
#import <React/RCTViewManager.h>
|
|
22
|
+
|
|
23
|
+
@interface RCTFBSDKLoginButtonManager : RCTViewManager
|
|
24
|
+
|
|
25
|
+
@end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
4
|
+
// copy, modify, and distribute this software in source code or binary form for use
|
|
5
|
+
// in connection with the web services and APIs provided by Facebook.
|
|
6
|
+
//
|
|
7
|
+
// As with any software that integrates with the Facebook platform, your use of
|
|
8
|
+
// this software is subject to the Facebook Developer Principles and Policies
|
|
9
|
+
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
10
|
+
// included in all copies or substantial portions of the software.
|
|
11
|
+
//
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
14
|
+
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
16
|
+
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
17
|
+
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
#import "RCTFBSDKLoginButtonManager.h"
|
|
20
|
+
#import "RCTFBSDKLoginButtonView.h"
|
|
21
|
+
|
|
22
|
+
#import <React/RCTComponentEvent.h>
|
|
23
|
+
#import <React/RCTEventDispatcher.h>
|
|
24
|
+
#import <React/RCTUtils.h>
|
|
25
|
+
#import <React/UIView+React.h>
|
|
26
|
+
|
|
27
|
+
#import "RCTConvert+FBSDKLogin.h"
|
|
28
|
+
|
|
29
|
+
@implementation RCTFBSDKLoginButtonManager
|
|
30
|
+
|
|
31
|
+
RCT_EXPORT_MODULE(RCTFBLoginButton)
|
|
32
|
+
|
|
33
|
+
#pragma mark - Object Lifecycle
|
|
34
|
+
|
|
35
|
+
- (UIView *)view
|
|
36
|
+
{
|
|
37
|
+
return [[RCTFBSDKLoginButtonView alloc] init];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#pragma mark - Properties
|
|
41
|
+
|
|
42
|
+
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
|
43
|
+
|
|
44
|
+
RCT_CUSTOM_VIEW_PROPERTY(permissions, NSStringArray, RCTFBSDKLoginButtonView)
|
|
45
|
+
{
|
|
46
|
+
[view.loginButton setPermissions:json ? json : nil];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
RCT_CUSTOM_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience, RCTFBSDKLoginButtonView)
|
|
50
|
+
{
|
|
51
|
+
if (json)
|
|
52
|
+
{
|
|
53
|
+
[view.loginButton setDefaultAudience:[RCTConvert FBSDKDefaultAudience:json]];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
RCT_CUSTOM_VIEW_PROPERTY(nonceIOS, NSString, RCTFBSDKLoginButtonView)
|
|
58
|
+
{
|
|
59
|
+
[view.loginButton setNonce:json ? json : nil];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
RCT_CUSTOM_VIEW_PROPERTY(loginTrackingIOS, NSString, RCTFBSDKLoginButtonView)
|
|
63
|
+
{
|
|
64
|
+
[view.loginButton setLoginTracking:([json isEqualToString:@"limited"]) ? FBSDKLoginTrackingLimited : FBSDKLoginTrackingEnabled];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, RCTFBSDKLoginButtonView)
|
|
68
|
+
{
|
|
69
|
+
[view.loginButton setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#import <FBSDKLoginKit/FBSDKLoginKit.h>
|
|
2
|
+
|
|
3
|
+
#import <React/RCTComponent.h>
|
|
4
|
+
#import <React/RCTEventDispatcher.h>
|
|
5
|
+
|
|
6
|
+
@interface RCTFBSDKLoginButtonView: UIView<FBSDKLoginButtonDelegate>
|
|
7
|
+
|
|
8
|
+
@property (nonatomic, strong) FBSDKLoginButton *loginButton;
|
|
9
|
+
|
|
10
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
|
|
11
|
+
|
|
12
|
+
@end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#import "RCTFBSDKLoginButtonView.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTComponentEvent.h>
|
|
4
|
+
#import <React/RCTEventDispatcher.h>
|
|
5
|
+
#import <React/RCTUtils.h>
|
|
6
|
+
#import <React/UIView+React.h>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@interface RCTFBSDKLoginButtonView ()
|
|
10
|
+
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
@implementation RCTFBSDKLoginButtonView
|
|
14
|
+
|
|
15
|
+
- (instancetype)init
|
|
16
|
+
{
|
|
17
|
+
self = [super init];
|
|
18
|
+
if (self) {
|
|
19
|
+
self.loginButton = [[FBSDKLoginButton alloc] init];
|
|
20
|
+
self.loginButton.delegate = self;
|
|
21
|
+
self.loginButton.frame = self.bounds;
|
|
22
|
+
self.loginButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
23
|
+
|
|
24
|
+
[self addSubview:_loginButton];
|
|
25
|
+
|
|
26
|
+
return self;
|
|
27
|
+
}
|
|
28
|
+
return self;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#pragma mark - FBSDKLoginButtonDelegate
|
|
32
|
+
|
|
33
|
+
- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
|
|
34
|
+
{
|
|
35
|
+
NSDictionary *body = @{
|
|
36
|
+
@"type": @"loginFinished",
|
|
37
|
+
@"error": error ? RCTJSErrorFromNSError(error) : [NSNull null],
|
|
38
|
+
@"result": error ? [NSNull null] : @{
|
|
39
|
+
@"isCancelled": @(result.isCancelled),
|
|
40
|
+
@"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
|
|
41
|
+
@"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
self.onChange(body);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
|
|
49
|
+
{
|
|
50
|
+
NSDictionary *body = @{
|
|
51
|
+
@"type": @"logoutFinished",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
self.onChange(body);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
4
|
+
// copy, modify, and distribute this software in source code or binary form for use
|
|
5
|
+
// in connection with the web services and APIs provided by Facebook.
|
|
6
|
+
//
|
|
7
|
+
// As with any software that integrates with the Facebook platform, your use of
|
|
8
|
+
// this software is subject to the Facebook Developer Principles and Policies
|
|
9
|
+
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
10
|
+
// included in all copies or substantial portions of the software.
|
|
11
|
+
//
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
14
|
+
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
16
|
+
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
17
|
+
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
#import <React/RCTBridgeModule.h>
|
|
20
|
+
|
|
21
|
+
@interface RCTFBSDKLoginManager : NSObject <RCTBridgeModule>
|
|
22
|
+
@end
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
4
|
+
// copy, modify, and distribute this software in source code or binary form for use
|
|
5
|
+
// in connection with the web services and APIs provided by Facebook.
|
|
6
|
+
//
|
|
7
|
+
// As with any software that integrates with the Facebook platform, your use of
|
|
8
|
+
// this software is subject to the Facebook Developer Principles and Policies
|
|
9
|
+
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
10
|
+
// included in all copies or substantial portions of the software.
|
|
11
|
+
//
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
14
|
+
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
16
|
+
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
17
|
+
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
#import "RCTFBSDKLoginManager.h"
|
|
20
|
+
|
|
21
|
+
#import <React/RCTUtils.h>
|
|
22
|
+
|
|
23
|
+
#import "RCTConvert+FBSDKLogin.h"
|
|
24
|
+
|
|
25
|
+
@implementation RCTFBSDKLoginManager
|
|
26
|
+
{
|
|
27
|
+
FBSDKLoginManager *_loginManager;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
RCT_EXPORT_MODULE(FBLoginManager);
|
|
31
|
+
|
|
32
|
+
#pragma mark - Object Lifecycle
|
|
33
|
+
|
|
34
|
+
- (dispatch_queue_t)methodQueue
|
|
35
|
+
{
|
|
36
|
+
return dispatch_get_main_queue();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (instancetype)init
|
|
40
|
+
{
|
|
41
|
+
if ((self = [super init])) {
|
|
42
|
+
_loginManager = [[FBSDKLoginManager alloc] init];
|
|
43
|
+
}
|
|
44
|
+
return self;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
+ (BOOL)requiresMainQueueSetup
|
|
48
|
+
{
|
|
49
|
+
return YES;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#pragma mark - React Native Methods
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
RCT_EXPORT_METHOD(setDefaultAudience:(FBSDKDefaultAudience)audience)
|
|
56
|
+
{
|
|
57
|
+
_loginManager.defaultAudience = audience;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
RCT_REMAP_METHOD(getDefaultAudience, getDefaultAudience_resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
61
|
+
{
|
|
62
|
+
resolve(DefaultAudienceToString([_loginManager defaultAudience]));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
RCT_EXPORT_METHOD(logInWithPermissions:(NSArray<NSString *> *)permissions
|
|
66
|
+
loginTracking: (NSString *)loginTracking
|
|
67
|
+
nonce: (NSString *)nonce
|
|
68
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
69
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
70
|
+
{
|
|
71
|
+
FBSDKLoginManagerLoginResultBlock requestHandler = ^(FBSDKLoginManagerLoginResult *result, NSError *error) {
|
|
72
|
+
if (error) {
|
|
73
|
+
reject(@"FacebookSDK", @"Login Failed", error);
|
|
74
|
+
} else {
|
|
75
|
+
resolve(RCTBuildResultDictionary(result));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
FBSDKLoginConfiguration *configuration;
|
|
79
|
+
FBSDKLoginTracking tracking = [loginTracking isEqualToString: @"limited"] ? FBSDKLoginTrackingLimited : FBSDKLoginTrackingEnabled;
|
|
80
|
+
|
|
81
|
+
if ( ( ![nonce isEqual:[NSNull null]] ) && ( [nonce length] != 0 ) ) {
|
|
82
|
+
configuration =
|
|
83
|
+
[[FBSDKLoginConfiguration alloc] initWithPermissions:permissions
|
|
84
|
+
tracking: tracking
|
|
85
|
+
nonce:nonce
|
|
86
|
+
];
|
|
87
|
+
} else {
|
|
88
|
+
configuration =
|
|
89
|
+
[[FBSDKLoginConfiguration alloc] initWithPermissions:permissions
|
|
90
|
+
tracking: tracking
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[_loginManager
|
|
95
|
+
logInFromViewController: nil
|
|
96
|
+
configuration:configuration
|
|
97
|
+
completion:requestHandler];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
RCT_EXPORT_METHOD(reauthorizeDataAccess:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
101
|
+
{
|
|
102
|
+
FBSDKLoginManagerLoginResultBlock requestHandler = ^(FBSDKLoginManagerLoginResult *result, NSError *error) {
|
|
103
|
+
if (error) {
|
|
104
|
+
reject(@"FacebookSDK", @"Reauthorization Failed", error);
|
|
105
|
+
} else {
|
|
106
|
+
resolve(RCTBuildResultDictionary(result));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// the nil argument is a ViewController, it should be nullable but Xcode complains
|
|
111
|
+
// I logged an upstream bug (and proposed a PR), hopefully will resolve.
|
|
112
|
+
// https://github.com/facebook/facebook-ios-sdk/issues/2476
|
|
113
|
+
#pragma clang diagnostic push
|
|
114
|
+
#pragma clang diagnostic ignored "-Wnonnull"
|
|
115
|
+
[_loginManager reauthorizeDataAccess:nil handler:requestHandler];
|
|
116
|
+
#pragma clang diagnostic pop
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
RCT_EXPORT_METHOD(logOut)
|
|
120
|
+
{
|
|
121
|
+
[_loginManager logOut];
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
#pragma mark - Helper Methods
|
|
125
|
+
|
|
126
|
+
static NSDictionary *RCTBuildResultDictionary(FBSDKLoginManagerLoginResult *result)
|
|
127
|
+
{
|
|
128
|
+
return @{
|
|
129
|
+
@"isCancelled": @(result.isCancelled),
|
|
130
|
+
@"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects,
|
|
131
|
+
@"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static NSString *DefaultAudienceToString(FBSDKDefaultAudience defaultAudience)
|
|
136
|
+
{
|
|
137
|
+
NSString *result = nil;
|
|
138
|
+
switch (defaultAudience) {
|
|
139
|
+
case FBSDKDefaultAudienceFriends:
|
|
140
|
+
result = @"friends";
|
|
141
|
+
break;
|
|
142
|
+
case FBSDKDefaultAudienceEveryone:
|
|
143
|
+
result = @"everyone";
|
|
144
|
+
break;
|
|
145
|
+
case FBSDKDefaultAudienceOnlyMe:
|
|
146
|
+
result = @"only-me";
|
|
147
|
+
break;
|
|
148
|
+
default:
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
4
|
+
// copy, modify, and distribute this software in source code or binary form for use
|
|
5
|
+
// in connection with the web services and APIs provided by Facebook.
|
|
6
|
+
//
|
|
7
|
+
// As with any software that integrates with the Facebook platform, your use of
|
|
8
|
+
// this software is subject to the Facebook Developer Principles and Policies
|
|
9
|
+
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
10
|
+
// included in all copies or substantial portions of the software.
|
|
11
|
+
//
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
14
|
+
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
16
|
+
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
17
|
+
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
#import <React/RCTConvert.h>
|
|
20
|
+
|
|
21
|
+
#import <FBSDKShareKit/FBSDKShareKit.h>
|
|
22
|
+
|
|
23
|
+
typedef id<FBSDKSharingContent> RCTFBSDKSharingContent;
|
|
24
|
+
|
|
25
|
+
@interface RCTConvert(FBSDKSharingContent)
|
|
26
|
+
|
|
27
|
+
+ (RCTFBSDKSharingContent)RCTFBSDKSharingContent:(id)json;
|
|
28
|
+
|
|
29
|
+
@end
|