@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
|
+
/**
|
|
2
|
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
5
|
+
* copy, modify, and distribute this software in source code or binary form for use
|
|
6
|
+
* in connection with the web services and APIs provided by Facebook.
|
|
7
|
+
*
|
|
8
|
+
* As with any software that integrates with the Facebook platform, your use of
|
|
9
|
+
* this software is subject to the Facebook Developer Principles and Policies
|
|
10
|
+
* [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
11
|
+
* included in all copies or substantial portions of the software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
16
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
package com.facebook.reactnative.androidsdk;
|
|
22
|
+
|
|
23
|
+
import com.facebook.FacebookCallback;
|
|
24
|
+
import com.facebook.FacebookException;
|
|
25
|
+
import com.facebook.react.bridge.Arguments;
|
|
26
|
+
import com.facebook.react.bridge.Promise;
|
|
27
|
+
import com.facebook.react.bridge.WritableMap;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A callback class fulfilled by Promise for the React Native Facebook SDK.
|
|
31
|
+
* @param <RESULT>
|
|
32
|
+
*/
|
|
33
|
+
public abstract class ReactNativeFacebookSDKCallback <RESULT> implements FacebookCallback<RESULT> {
|
|
34
|
+
|
|
35
|
+
Promise mPromise;
|
|
36
|
+
|
|
37
|
+
public ReactNativeFacebookSDKCallback(Promise promise) {
|
|
38
|
+
mPromise = promise;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
public void onCancel() {
|
|
43
|
+
if (mPromise != null) {
|
|
44
|
+
WritableMap result = Arguments.createMap();
|
|
45
|
+
result.putBoolean("isCancelled", true);
|
|
46
|
+
mPromise.resolve(result);
|
|
47
|
+
mPromise = null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
public void onError(FacebookException error) {
|
|
53
|
+
if (mPromise != null) {
|
|
54
|
+
mPromise.reject(error);
|
|
55
|
+
mPromise = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
3
|
+
* <p/>
|
|
4
|
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
|
5
|
+
* copy, modify, and distribute this software in source code or binary form for use
|
|
6
|
+
* in connection with the web services and APIs provided by Facebook.
|
|
7
|
+
* <p/>
|
|
8
|
+
* As with any software that integrates with the Facebook platform, your use of
|
|
9
|
+
* this software is subject to the Facebook Developer Principles and Policies
|
|
10
|
+
* [http://developers.facebook.com/policy/]. This copyright notice shall be
|
|
11
|
+
* included in all copies or substantial portions of the software.
|
|
12
|
+
* <p/>
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
16
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
package com.facebook.reactnative.androidsdk;
|
|
22
|
+
|
|
23
|
+
import android.net.Uri;
|
|
24
|
+
|
|
25
|
+
import com.facebook.AccessToken;
|
|
26
|
+
import com.facebook.AccessTokenSource;
|
|
27
|
+
import com.facebook.Profile;
|
|
28
|
+
import com.facebook.react.bridge.Arguments;
|
|
29
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
30
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
31
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
32
|
+
import com.facebook.react.bridge.WritableArray;
|
|
33
|
+
import com.facebook.react.bridge.WritableMap;
|
|
34
|
+
import com.facebook.share.model.GameRequestContent;
|
|
35
|
+
import com.facebook.share.model.ShareContent;
|
|
36
|
+
import com.facebook.share.model.ShareLinkContent;
|
|
37
|
+
import com.facebook.share.model.ShareHashtag;
|
|
38
|
+
import com.facebook.share.model.SharePhoto;
|
|
39
|
+
import com.facebook.share.model.SharePhotoContent;
|
|
40
|
+
import com.facebook.share.model.ShareVideo;
|
|
41
|
+
import com.facebook.share.model.ShareVideoContent;
|
|
42
|
+
|
|
43
|
+
import java.util.ArrayList;
|
|
44
|
+
import java.util.Date;
|
|
45
|
+
import java.util.List;
|
|
46
|
+
import java.util.Locale;
|
|
47
|
+
import java.util.Set;
|
|
48
|
+
|
|
49
|
+
import androidx.annotation.Nullable;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This class is solely for the use of other packages within the React Native Facebook SDK for Android.
|
|
54
|
+
* Use of any of the classes in this package is unsupported, and they may be modified or removed
|
|
55
|
+
* without warning at any time.
|
|
56
|
+
*/
|
|
57
|
+
public final class Utility {
|
|
58
|
+
|
|
59
|
+
public static AccessToken buildAccessToken(ReadableMap accessTokenMap) {
|
|
60
|
+
return new AccessToken(
|
|
61
|
+
accessTokenMap.getString("accessToken"),
|
|
62
|
+
accessTokenMap.getString("applicationID"),
|
|
63
|
+
accessTokenMap.getString("userID"),
|
|
64
|
+
accessTokenMap.hasKey("permissions") && !accessTokenMap.isNull("permissions") ? reactArrayToStringList(accessTokenMap.getArray("permissions")) : null,
|
|
65
|
+
accessTokenMap.hasKey("declinedPermissions") && !accessTokenMap.isNull("declinedPermissions") ? reactArrayToStringList(accessTokenMap.getArray("declinedPermissions")) : null,
|
|
66
|
+
accessTokenMap.hasKey("expiredPermissions") && !accessTokenMap.isNull("expiredPermissions") ? reactArrayToStringList(accessTokenMap.getArray("expiredPermissions")) : null,
|
|
67
|
+
accessTokenMap.hasKey("accessTokenSource") && !accessTokenMap.isNull("accessTokenSource") ? AccessTokenSource.valueOf(accessTokenMap.getString("accessTokenSource")) : null,
|
|
68
|
+
accessTokenMap.hasKey("expirationTime") && !accessTokenMap.isNull("expirationTime") ? new Date((long) accessTokenMap.getDouble("expirationTime")) : null,
|
|
69
|
+
accessTokenMap.hasKey("lastRefreshTime") && !accessTokenMap.isNull("lastRefreshTime") ? new Date((long) accessTokenMap.getDouble("lastRefreshTime")) : null,
|
|
70
|
+
accessTokenMap.hasKey("dataAccessExpirationTime") && !accessTokenMap.isNull("dataAccessExpirationTime") ? new Date((long) accessTokenMap.getDouble("dataAccessExpirationTime")) : null
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public static WritableMap accessTokenToReactMap(AccessToken accessToken) {
|
|
75
|
+
WritableMap map = Arguments.createMap();
|
|
76
|
+
map.putString("accessToken", accessToken.getToken());
|
|
77
|
+
map.putString("applicationID", accessToken.getApplicationId());
|
|
78
|
+
map.putString("userID", accessToken.getUserId());
|
|
79
|
+
map.putArray(
|
|
80
|
+
"permissions",
|
|
81
|
+
Arguments.fromJavaArgs(setToStringArray(accessToken.getPermissions())));
|
|
82
|
+
map.putArray(
|
|
83
|
+
"declinedPermissions",
|
|
84
|
+
Arguments.fromJavaArgs(setToStringArray(accessToken.getDeclinedPermissions())));
|
|
85
|
+
map.putArray(
|
|
86
|
+
"expiredPermissions",
|
|
87
|
+
Arguments.fromJavaArgs(setToStringArray(accessToken.getExpiredPermissions())));
|
|
88
|
+
map.putString("accessTokenSource", accessToken.getSource().name());
|
|
89
|
+
map.putDouble("expirationTime", (double) accessToken.getExpires().getTime());
|
|
90
|
+
map.putDouble("lastRefreshTime", (double) accessToken.getLastRefresh().getTime());
|
|
91
|
+
map.putDouble("dataAccessExpirationTime", (double) accessToken.getDataAccessExpirationTime().getTime());
|
|
92
|
+
return map;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public static WritableMap profileToReactMap(Profile profile) {
|
|
96
|
+
WritableMap map = Arguments.createMap();
|
|
97
|
+
|
|
98
|
+
String name = profile.getName();
|
|
99
|
+
Utility.putStringOrNull(map, "name", name);
|
|
100
|
+
|
|
101
|
+
String firstName = profile.getFirstName();
|
|
102
|
+
Utility.putStringOrNull(map, "firstName", firstName);
|
|
103
|
+
|
|
104
|
+
String lastName = profile.getLastName();
|
|
105
|
+
Utility.putStringOrNull(map, "lastName", lastName);
|
|
106
|
+
|
|
107
|
+
String middleName = profile.getMiddleName();
|
|
108
|
+
Utility.putStringOrNull(map, "middleName", middleName);
|
|
109
|
+
|
|
110
|
+
Uri profilePictureUri = profile.getProfilePictureUri(100, 100);
|
|
111
|
+
Utility.putStringOrNull(map, "imageURL", profilePictureUri.toString());
|
|
112
|
+
|
|
113
|
+
Uri linkUri = profile.getLinkUri();
|
|
114
|
+
Utility.putStringOrNull(map, "linkURL", linkUri.toString());
|
|
115
|
+
|
|
116
|
+
String userId = profile.getId();
|
|
117
|
+
Utility.putStringOrNull(map, "userID", userId);
|
|
118
|
+
|
|
119
|
+
return map;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public static ShareContent buildShareContent(ReadableMap shareContentMap) {
|
|
123
|
+
ShareContent shareContent = null;
|
|
124
|
+
if (shareContentMap != null) {
|
|
125
|
+
String contentType = shareContentMap.getString("contentType");
|
|
126
|
+
if (contentType.equals("link")) {
|
|
127
|
+
shareContent = buildShareLinkContent(shareContentMap);
|
|
128
|
+
} else if (contentType.equals("photo")) {
|
|
129
|
+
shareContent = buildSharePhotoContent(shareContentMap);
|
|
130
|
+
} else if (contentType.equals("video")) {
|
|
131
|
+
shareContent = buildShareVideoContent(shareContentMap);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return shareContent;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public static GameRequestContent buildGameRequestContent(ReadableMap gameRequestContentMap) {
|
|
138
|
+
GameRequestContent.Builder gameRequestContentBuilder = new GameRequestContent.Builder();
|
|
139
|
+
String actionType = getValueOrNull(gameRequestContentMap, "actionType");
|
|
140
|
+
if (actionType != null) {
|
|
141
|
+
gameRequestContentBuilder.setActionType(
|
|
142
|
+
GameRequestContent.ActionType.valueOf(actionType.toUpperCase(Locale.ROOT)));
|
|
143
|
+
}
|
|
144
|
+
String filters = getValueOrNull(gameRequestContentMap, "filters");
|
|
145
|
+
if (filters != null) {
|
|
146
|
+
gameRequestContentBuilder.setFilters(
|
|
147
|
+
GameRequestContent.Filters.valueOf(filters.toUpperCase(Locale.ROOT)));
|
|
148
|
+
}
|
|
149
|
+
gameRequestContentBuilder.setMessage(gameRequestContentMap.getString("message"));
|
|
150
|
+
if (gameRequestContentMap.hasKey("recipients")) {
|
|
151
|
+
gameRequestContentBuilder.setRecipients(
|
|
152
|
+
reactArrayToStringList(gameRequestContentMap.getArray("recipients")));
|
|
153
|
+
}
|
|
154
|
+
gameRequestContentBuilder.setTitle(getValueOrNull(gameRequestContentMap, "title"));
|
|
155
|
+
gameRequestContentBuilder.setData(getValueOrNull(gameRequestContentMap, "data"));
|
|
156
|
+
gameRequestContentBuilder.setObjectId(getValueOrNull(gameRequestContentMap, "objectId"));
|
|
157
|
+
if (gameRequestContentMap.hasKey("suggestions")) {
|
|
158
|
+
gameRequestContentBuilder.setSuggestions(reactArrayToStringList(
|
|
159
|
+
gameRequestContentMap.getArray("suggestions")));
|
|
160
|
+
}
|
|
161
|
+
return gameRequestContentBuilder.build();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public static ShareLinkContent buildShareLinkContent(ReadableMap shareLinkContent) {
|
|
165
|
+
ShareLinkContent.Builder contentBuilder = new ShareLinkContent.Builder();
|
|
166
|
+
contentBuilder.setContentUrl(Uri.parse(shareLinkContent.getString("contentUrl")));
|
|
167
|
+
contentBuilder.setQuote(getValueOrNull(shareLinkContent, "quote"));
|
|
168
|
+
appendGenericContent(contentBuilder, shareLinkContent);
|
|
169
|
+
return contentBuilder.build();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public static SharePhotoContent buildSharePhotoContent(ReadableMap sharePhotoContent) {
|
|
173
|
+
SharePhotoContent.Builder contentBuilder = new SharePhotoContent.Builder();
|
|
174
|
+
contentBuilder.setPhotos(reactArrayToPhotoList(sharePhotoContent.getArray("photos")));
|
|
175
|
+
String url = getValueOrNull(sharePhotoContent, "contentUrl");
|
|
176
|
+
contentBuilder.setContentUrl(url != null ? Uri.parse(url) : null);
|
|
177
|
+
appendGenericContent(contentBuilder, sharePhotoContent);
|
|
178
|
+
return contentBuilder.build();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public static SharePhoto buildSharePhoto(ReadableMap photoMap) {
|
|
182
|
+
SharePhoto.Builder photoBuilder = new SharePhoto.Builder();
|
|
183
|
+
photoBuilder.setImageUrl(Uri.parse(photoMap.getString("imageUrl")));
|
|
184
|
+
photoBuilder.setCaption(getValueOrNull(photoMap, "caption"));
|
|
185
|
+
if (photoMap.hasKey("userGenerated")) {
|
|
186
|
+
photoBuilder.setUserGenerated(photoMap.getBoolean("userGenerated"));
|
|
187
|
+
}
|
|
188
|
+
return photoBuilder.build();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
public static ShareContent buildShareVideoContent(ReadableMap shareVideoContent) {
|
|
192
|
+
ShareVideoContent.Builder contentBuilder = new ShareVideoContent.Builder();
|
|
193
|
+
String url = getValueOrNull(shareVideoContent, "contentUrl");
|
|
194
|
+
contentBuilder.setContentUrl(url != null ? Uri.parse(url) : null);
|
|
195
|
+
contentBuilder.setContentDescription(
|
|
196
|
+
getValueOrNull(shareVideoContent, "contentDescription"));
|
|
197
|
+
contentBuilder.setContentTitle(getValueOrNull(shareVideoContent, "contentTitle"));
|
|
198
|
+
if (shareVideoContent.hasKey("previewPhoto")) {
|
|
199
|
+
contentBuilder.setPreviewPhoto(buildSharePhoto(shareVideoContent.getMap("previewPhoto")));
|
|
200
|
+
}
|
|
201
|
+
if (shareVideoContent.hasKey("video")) {
|
|
202
|
+
contentBuilder.setVideo(buildShareVideo(shareVideoContent.getMap("video")));
|
|
203
|
+
}
|
|
204
|
+
appendGenericContent(contentBuilder, shareVideoContent);
|
|
205
|
+
return contentBuilder.build();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private static void appendGenericContent(ShareContent.Builder contentBuilder, ReadableMap shareContent) {
|
|
209
|
+
if (shareContent.hasKey("commonParameters")) {
|
|
210
|
+
ReadableMap commonParameters = shareContent.getMap("commonParameters");
|
|
211
|
+
contentBuilder.setPeopleIds(
|
|
212
|
+
commonParameters.hasKey("peopleIds")
|
|
213
|
+
? reactArrayToStringList(commonParameters.getArray("peopleIds"))
|
|
214
|
+
: null);
|
|
215
|
+
contentBuilder.setPlaceId(getValueOrNull(commonParameters, "placeId"));
|
|
216
|
+
contentBuilder.setRef(getValueOrNull(commonParameters, "ref"));
|
|
217
|
+
if (commonParameters.hasKey("hashtag")) {
|
|
218
|
+
ShareHashtag tag = new ShareHashtag.Builder().setHashtag(commonParameters.getString("hashtag")).build();
|
|
219
|
+
contentBuilder.setShareHashtag(tag);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public static ShareVideo buildShareVideo(ReadableMap videoMap) {
|
|
225
|
+
ShareVideo.Builder videoBuilder = new ShareVideo.Builder();
|
|
226
|
+
if (videoMap.hasKey("localUrl")) {
|
|
227
|
+
videoBuilder.setLocalUrl(Uri.parse(videoMap.getString("localUrl")));
|
|
228
|
+
}
|
|
229
|
+
return videoBuilder.build();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public static List<SharePhoto> reactArrayToPhotoList(ReadableArray photos) {
|
|
233
|
+
List<SharePhoto> list = new ArrayList<>(photos.size());
|
|
234
|
+
for (int i = 0; i < photos.size(); i++) {
|
|
235
|
+
ReadableMap photoDetail = photos.getMap(i);
|
|
236
|
+
list.add(buildSharePhoto(photoDetail));
|
|
237
|
+
}
|
|
238
|
+
return list;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
public static String getValueOrNull(ReadableMap map, String key) {
|
|
242
|
+
if (map.hasKey(key)) {
|
|
243
|
+
return map.getString(key);
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public static @Nullable List<String> reactArrayToStringList(@Nullable ReadableArray array) {
|
|
249
|
+
if (array == null) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
List<String> list = new ArrayList<>(array.size());
|
|
253
|
+
for (int i = 0; i < array.size(); i++) {
|
|
254
|
+
list.add(array.getString(i));
|
|
255
|
+
}
|
|
256
|
+
return list;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
public static WritableArray listToReactArray(List<String> list) {
|
|
260
|
+
WritableArray array = Arguments.createArray();
|
|
261
|
+
for (String e: list) {
|
|
262
|
+
array.pushString(e);
|
|
263
|
+
}
|
|
264
|
+
return array;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
public static String[] setToStringArray(Set<String> set) {
|
|
268
|
+
String[] array = new String[set.size()];
|
|
269
|
+
int i = 0;
|
|
270
|
+
for (String e : set) {
|
|
271
|
+
array[i++] = e;
|
|
272
|
+
}
|
|
273
|
+
return array;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private static void putStringOrNull(WritableMap map, String key, String value) {
|
|
277
|
+
if (value == null) {
|
|
278
|
+
map.putNull(key);
|
|
279
|
+
} else {
|
|
280
|
+
map.putString(key, value);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build/withFacebook');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import FBSDKCoreKit
|
|
3
|
+
|
|
4
|
+
public class FacebookAppDelegate: ExpoAppDelegateSubscriber {
|
|
5
|
+
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
|
6
|
+
ApplicationDelegate.shared.application(
|
|
7
|
+
application,
|
|
8
|
+
didFinishLaunchingWithOptions: launchOptions
|
|
9
|
+
)
|
|
10
|
+
return true
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
|
14
|
+
return ApplicationDelegate.shared.application(
|
|
15
|
+
application,
|
|
16
|
+
open: url,
|
|
17
|
+
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
|
|
18
|
+
annotation: options[UIApplication.OpenURLOptionsKey.annotation]
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'ExpoAdapterFBSDKNext'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.description = package['description']
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.homepage = package['homepage']
|
|
13
|
+
s.platform = :ios, '13.0'
|
|
14
|
+
s.swift_version = '5.4'
|
|
15
|
+
s.source = { :git => 'https://github.com/thebergamo/react-native-fbsdk-next.git', :tag => "v#{package['version']}" }
|
|
16
|
+
s.static_framework = true
|
|
17
|
+
|
|
18
|
+
s.dependency 'ExpoModulesCore'
|
|
19
|
+
s.dependency 'React-Core'
|
|
20
|
+
s.dependency 'FBSDKCoreKit'
|
|
21
|
+
|
|
22
|
+
# Swift/Objective-C compatibility
|
|
23
|
+
s.pod_target_xcconfig = {
|
|
24
|
+
'DEFINES_MODULE' => 'YES'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
|
|
28
|
+
s.source_files = "#{s.name}/**/*.h"
|
|
29
|
+
s.vendored_frameworks = "#{s.name}.xcframework"
|
|
30
|
+
else
|
|
31
|
+
s.source_files = "#{s.name}/**/*.{h,m,swift}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
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 <FBSDKCoreKit/FBSDKCoreKit.h>
|
|
22
|
+
|
|
23
|
+
@interface RCTConvert (FBSDKAccessToken)
|
|
24
|
+
|
|
25
|
+
+ (FBSDKAccessToken *)FBSDKAccessToken:(id)json;
|
|
26
|
+
|
|
27
|
+
@end
|
|
@@ -0,0 +1,41 @@
|
|
|
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+FBSDKAccessToken.h"
|
|
20
|
+
|
|
21
|
+
@implementation RCTConvert (FBSDKAccessToken)
|
|
22
|
+
|
|
23
|
+
+ (FBSDKAccessToken *)FBSDKAccessToken:(id)json
|
|
24
|
+
{
|
|
25
|
+
NSDictionary *data = [RCTConvert NSDictionary:json];
|
|
26
|
+
if (data.count > 0) {
|
|
27
|
+
return [[FBSDKAccessToken alloc]
|
|
28
|
+
initWithTokenString:[RCTConvert NSString:data[@"accessToken"]]
|
|
29
|
+
permissions:[RCTConvert NSStringArray:data[@"permissions"]]
|
|
30
|
+
declinedPermissions:[RCTConvert NSStringArray:data[@"declinedPermissions"]]
|
|
31
|
+
expiredPermissions:[RCTConvert NSStringArray:data[@"expiredPermissions"]]
|
|
32
|
+
appID:[RCTConvert NSString:data[@"applicationID"]]
|
|
33
|
+
userID:[RCTConvert NSString:data[@"userID"]]
|
|
34
|
+
expirationDate:[RCTConvert NSDate:data[@"expirationTime"]]
|
|
35
|
+
refreshDate:[RCTConvert NSDate:data[@"lastRefreshTime"]]
|
|
36
|
+
dataAccessExpirationDate:[RCTConvert NSDate:data[@"dataAccessExpirationTime"]]];
|
|
37
|
+
}
|
|
38
|
+
return nil;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTFBSDKAEMReporter.m
|
|
3
|
+
// react-native-fbsdk-next
|
|
4
|
+
//
|
|
5
|
+
// Created by rnike@gitub on 2021/12/17.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTBridgeModule.h>
|
|
9
|
+
#import <React/RCTUtils.h>
|
|
10
|
+
#import <FBAEMKit/FBAEMKit-Swift.h>
|
|
11
|
+
|
|
12
|
+
@interface RCTFBSDKAEMReporter : NSObject <RCTBridgeModule>
|
|
13
|
+
@end
|
|
14
|
+
|
|
15
|
+
@implementation RCTFBSDKAEMReporter
|
|
16
|
+
|
|
17
|
+
RCT_EXPORT_MODULE();
|
|
18
|
+
|
|
19
|
+
RCT_EXPORT_METHOD(recordAndUpdateEvent:(NSString *)eventName
|
|
20
|
+
value:(NSNumber * __nonnull)value
|
|
21
|
+
currency:(NSString * _Nullable)currency
|
|
22
|
+
otherParameters:(NSDictionary<NSString *,id> * _Nullable)otherParameters)
|
|
23
|
+
{
|
|
24
|
+
[FBAEMReporter recordAndUpdateEvent:eventName
|
|
25
|
+
currency:currency
|
|
26
|
+
value:value
|
|
27
|
+
parameters:otherParameters];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@end
|
|
@@ -0,0 +1,24 @@
|
|
|
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/RCTEventEmitter.h>
|
|
20
|
+
|
|
21
|
+
#import <FBSDKCoreKit/FBSDKCoreKit.h>
|
|
22
|
+
|
|
23
|
+
@interface RCTFBSDKAccessToken : RCTEventEmitter
|
|
24
|
+
@end
|
|
@@ -0,0 +1,115 @@
|
|
|
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 "RCTFBSDKAccessToken.h"
|
|
20
|
+
|
|
21
|
+
#import <React/RCTUtils.h>
|
|
22
|
+
|
|
23
|
+
#import "RCTConvert+FBSDKAccessToken.h"
|
|
24
|
+
|
|
25
|
+
static NSString *const kFBSDKAccessTokenDidChangeEvent = @"fbsdk.accessTokenDidChange";
|
|
26
|
+
|
|
27
|
+
@implementation RCTFBSDKAccessToken {
|
|
28
|
+
BOOL _isObserving;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
RCT_EXPORT_MODULE(FBAccessToken);
|
|
32
|
+
|
|
33
|
+
- (dispatch_queue_t)methodQueue
|
|
34
|
+
{
|
|
35
|
+
return dispatch_get_main_queue();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#pragma mark - React Native Methods
|
|
39
|
+
|
|
40
|
+
RCT_EXPORT_METHOD(getCurrentAccessToken:(RCTResponseSenderBlock)callback)
|
|
41
|
+
{
|
|
42
|
+
FBSDKAccessToken *currentToken = [FBSDKAccessToken currentAccessToken];
|
|
43
|
+
NSDictionary *tokenDict = RCTBuildAccessTokenDict(currentToken);
|
|
44
|
+
callback(@[RCTNullIfNil(tokenDict)]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
RCT_EXPORT_METHOD(setCurrentAccessToken:(FBSDKAccessToken *)token)
|
|
48
|
+
{
|
|
49
|
+
[FBSDKAccessToken setCurrentAccessToken:token];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
RCT_EXPORT_METHOD(refreshCurrentAccessTokenAsync:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
53
|
+
{
|
|
54
|
+
[FBSDKAccessToken refreshCurrentAccessTokenWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
|
|
55
|
+
if (error) {
|
|
56
|
+
reject(@"FacebookSDK", error.localizedDescription, error);
|
|
57
|
+
} else {
|
|
58
|
+
resolve(result);
|
|
59
|
+
}
|
|
60
|
+
}];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#pragma mark - Event Methods
|
|
64
|
+
|
|
65
|
+
- (NSArray *)supportedEvents
|
|
66
|
+
{
|
|
67
|
+
return @[kFBSDKAccessTokenDidChangeEvent];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (void)startObserving
|
|
71
|
+
{
|
|
72
|
+
_isObserving = YES;
|
|
73
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
74
|
+
selector:@selector(accessTokenDidChange:)
|
|
75
|
+
name:FBSDKAccessTokenDidChangeNotification
|
|
76
|
+
object:nil];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (void)stopObserving
|
|
80
|
+
{
|
|
81
|
+
_isObserving = NO;
|
|
82
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self
|
|
83
|
+
name:FBSDKAccessTokenDidChangeNotification
|
|
84
|
+
object:nil];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
- (void)accessTokenDidChange:(NSNotification*)notification
|
|
88
|
+
{
|
|
89
|
+
if ([notification.name isEqualToString:FBSDKAccessTokenDidChangeNotification] && _isObserving) {
|
|
90
|
+
NSDictionary *body = RCTBuildAccessTokenDict([FBSDKAccessToken currentAccessToken]);
|
|
91
|
+
[self sendEventWithName:kFBSDKAccessTokenDidChangeEvent body:body ?: [NSNull null]];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#pragma mark - Helper Functions
|
|
96
|
+
|
|
97
|
+
static NSDictionary *RCTBuildAccessTokenDict(FBSDKAccessToken *token)
|
|
98
|
+
{
|
|
99
|
+
if (!token) {
|
|
100
|
+
return nil;
|
|
101
|
+
}
|
|
102
|
+
return @{
|
|
103
|
+
@"accessToken": token.tokenString,
|
|
104
|
+
@"permissions": token.permissions.allObjects,
|
|
105
|
+
@"declinedPermissions": token.declinedPermissions.allObjects,
|
|
106
|
+
@"expiredPermissions": token.expiredPermissions.allObjects,
|
|
107
|
+
@"applicationID": token.appID,
|
|
108
|
+
@"userID": token.userID,
|
|
109
|
+
@"expirationTime": @(token.expirationDate.timeIntervalSince1970 * 1000),
|
|
110
|
+
@"lastRefreshTime": @(token.refreshDate.timeIntervalSince1970 * 1000),
|
|
111
|
+
@"dataAccessExpirationTime": @(token.dataAccessExpirationDate.timeIntervalSince1970 * 1000),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@end
|