@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.
Files changed (284) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +943 -0
  3. package/android/build.gradle +57 -0
  4. package/android/src/main/AndroidManifest.xml +46 -0
  5. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBAccessTokenModule.java +151 -0
  6. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBActivityEventListener.java +40 -0
  7. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBAppEventsLoggerModule.java +414 -0
  8. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBAppLinkModule.java +86 -0
  9. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBGameRequestDialogModule.java +94 -0
  10. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBGraphRequestModule.java +283 -0
  11. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBLoginButtonManager.java +83 -0
  12. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBLoginManagerModule.java +171 -0
  13. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBMessageDialogModule.java +111 -0
  14. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBProfileModule.java +68 -0
  15. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKCallbackManagerBaseJavaModule.java +41 -0
  16. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKPackage.java +60 -0
  17. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBSendButtonManager.java +51 -0
  18. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBSettingsModule.java +95 -0
  19. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBShareButtonManager.java +53 -0
  20. package/android/src/main/java/com/facebook/reactnative/androidsdk/FBShareDialogModule.java +107 -0
  21. package/android/src/main/java/com/facebook/reactnative/androidsdk/RCTLoginButton.java +126 -0
  22. package/android/src/main/java/com/facebook/reactnative/androidsdk/RCTLoginButtonEvent.java +27 -0
  23. package/android/src/main/java/com/facebook/reactnative/androidsdk/ReactNativeFacebookSDKCallback.java +58 -0
  24. package/android/src/main/java/com/facebook/reactnative/androidsdk/Utility.java +283 -0
  25. package/app.plugin.js +1 -0
  26. package/expo-module.config.json +10 -0
  27. package/ios/ExpoAdapterFBSDKNext/FacebookAppDelegate.swift +21 -0
  28. package/ios/ExpoAdapterFBSDKNext.podspec +33 -0
  29. package/ios/RCTFBSDK/core/RCTConvert+FBSDKAccessToken.h +27 -0
  30. package/ios/RCTFBSDK/core/RCTConvert+FBSDKAccessToken.m +41 -0
  31. package/ios/RCTFBSDK/core/RCTFBSDKAEMReporter.m +30 -0
  32. package/ios/RCTFBSDK/core/RCTFBSDKAccessToken.h +24 -0
  33. package/ios/RCTFBSDK/core/RCTFBSDKAccessToken.m +115 -0
  34. package/ios/RCTFBSDK/core/RCTFBSDKAppEvents.h +24 -0
  35. package/ios/RCTFBSDK/core/RCTFBSDKAppEvents.m +251 -0
  36. package/ios/RCTFBSDK/core/RCTFBSDKAppLink.h +24 -0
  37. package/ios/RCTFBSDK/core/RCTFBSDKAppLink.m +52 -0
  38. package/ios/RCTFBSDK/core/RCTFBSDKAuthenticationToken.h +6 -0
  39. package/ios/RCTFBSDK/core/RCTFBSDKAuthenticationToken.m +35 -0
  40. package/ios/RCTFBSDK/core/RCTFBSDKGraphRequestConnectionContainer.h +50 -0
  41. package/ios/RCTFBSDK/core/RCTFBSDKGraphRequestConnectionContainer.m +124 -0
  42. package/ios/RCTFBSDK/core/RCTFBSDKGraphRequestManager.h +25 -0
  43. package/ios/RCTFBSDK/core/RCTFBSDKGraphRequestManager.m +43 -0
  44. package/ios/RCTFBSDK/core/RCTFBSDKProfile.h +6 -0
  45. package/ios/RCTFBSDK/core/RCTFBSDKProfile.m +58 -0
  46. package/ios/RCTFBSDK/core/RCTFBSDKSettings.h +14 -0
  47. package/ios/RCTFBSDK/core/RCTFBSDKSettings.m +80 -0
  48. package/ios/RCTFBSDK/login/RCTConvert+FBSDKLogin.h +28 -0
  49. package/ios/RCTFBSDK/login/RCTConvert+FBSDKLogin.m +35 -0
  50. package/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.h +25 -0
  51. package/ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m +73 -0
  52. package/ios/RCTFBSDK/login/RCTFBSDKLoginButtonView.h +12 -0
  53. package/ios/RCTFBSDK/login/RCTFBSDKLoginButtonView.m +57 -0
  54. package/ios/RCTFBSDK/login/RCTFBSDKLoginManager.h +22 -0
  55. package/ios/RCTFBSDK/login/RCTFBSDKLoginManager.m +154 -0
  56. package/ios/RCTFBSDK/share/RCTConvert+FBSDKSharingContent.h +29 -0
  57. package/ios/RCTFBSDK/share/RCTConvert+FBSDKSharingContent.m +111 -0
  58. package/ios/RCTFBSDK/share/RCTFBSDKGameRequestDialog.h +24 -0
  59. package/ios/RCTFBSDK/share/RCTFBSDKGameRequestDialog.m +134 -0
  60. package/ios/RCTFBSDK/share/RCTFBSDKMessageDialog.h +24 -0
  61. package/ios/RCTFBSDK/share/RCTFBSDKMessageDialog.m +116 -0
  62. package/ios/RCTFBSDK/share/RCTFBSDKSendButtonManager.h +25 -0
  63. package/ios/RCTFBSDK/share/RCTFBSDKSendButtonManager.m +39 -0
  64. package/ios/RCTFBSDK/share/RCTFBSDKShareButtonManager.h +23 -0
  65. package/ios/RCTFBSDK/share/RCTFBSDKShareButtonManager.m +39 -0
  66. package/ios/RCTFBSDK/share/RCTFBSDKShareDialog.h +24 -0
  67. package/ios/RCTFBSDK/share/RCTFBSDKShareDialog.m +134 -0
  68. package/ios/RCTFBSDK/share/RCTFBSDKShareHelper.h +21 -0
  69. package/ios/RCTFBSDK/share/RCTFBSDKShareHelper.m +32 -0
  70. package/ios/RCTFBSDK.xcodeproj/project.pbxproj +446 -0
  71. package/ios/RCTFBSDK.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  72. package/ios/RCTFBSDK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  73. package/jest/mocks/index.js +81 -0
  74. package/jest/setup.js +3 -0
  75. package/lib/commonjs/FBAEMReporter.js +39 -0
  76. package/lib/commonjs/FBAEMReporter.js.map +1 -0
  77. package/lib/commonjs/FBAccessToken.js +198 -0
  78. package/lib/commonjs/FBAccessToken.js.map +1 -0
  79. package/lib/commonjs/FBAppEventsLogger.js +221 -0
  80. package/lib/commonjs/FBAppEventsLogger.js.map +1 -0
  81. package/lib/commonjs/FBAppLink.js +36 -0
  82. package/lib/commonjs/FBAppLink.js.map +1 -0
  83. package/lib/commonjs/FBAuthenticationToken.js +55 -0
  84. package/lib/commonjs/FBAuthenticationToken.js.map +1 -0
  85. package/lib/commonjs/FBGameRequestDialog.js +45 -0
  86. package/lib/commonjs/FBGameRequestDialog.js.map +1 -0
  87. package/lib/commonjs/FBGraphRequest.js +66 -0
  88. package/lib/commonjs/FBGraphRequest.js.map +1 -0
  89. package/lib/commonjs/FBGraphRequestManager.js +96 -0
  90. package/lib/commonjs/FBGraphRequestManager.js.map +1 -0
  91. package/lib/commonjs/FBLoginButton.js +67 -0
  92. package/lib/commonjs/FBLoginButton.js.map +1 -0
  93. package/lib/commonjs/FBLoginManager.js +102 -0
  94. package/lib/commonjs/FBLoginManager.js.map +1 -0
  95. package/lib/commonjs/FBMessageDialog.js +51 -0
  96. package/lib/commonjs/FBMessageDialog.js.map +1 -0
  97. package/lib/commonjs/FBProfile.js +134 -0
  98. package/lib/commonjs/FBProfile.js.map +1 -0
  99. package/lib/commonjs/FBSendButton.js +48 -0
  100. package/lib/commonjs/FBSendButton.js.map +1 -0
  101. package/lib/commonjs/FBSettings.js +115 -0
  102. package/lib/commonjs/FBSettings.js.map +1 -0
  103. package/lib/commonjs/FBShareButton.js +48 -0
  104. package/lib/commonjs/FBShareButton.js.map +1 -0
  105. package/lib/commonjs/FBShareDialog.js +57 -0
  106. package/lib/commonjs/FBShareDialog.js.map +1 -0
  107. package/lib/commonjs/index.js +323 -0
  108. package/lib/commonjs/index.js.map +1 -0
  109. package/lib/commonjs/models/FBAppGroupCreationContent.js +2 -0
  110. package/lib/commonjs/models/FBAppGroupCreationContent.js.map +1 -0
  111. package/lib/commonjs/models/FBGameRequestContent.js +2 -0
  112. package/lib/commonjs/models/FBGameRequestContent.js.map +1 -0
  113. package/lib/commonjs/models/FBSDKCallback.js +2 -0
  114. package/lib/commonjs/models/FBSDKCallback.js.map +1 -0
  115. package/lib/commonjs/models/FBShareContent.js +6 -0
  116. package/lib/commonjs/models/FBShareContent.js.map +1 -0
  117. package/lib/commonjs/models/FBShareLinkContent.js +6 -0
  118. package/lib/commonjs/models/FBShareLinkContent.js.map +1 -0
  119. package/lib/commonjs/models/FBSharePhoto.js +2 -0
  120. package/lib/commonjs/models/FBSharePhoto.js.map +1 -0
  121. package/lib/commonjs/models/FBSharePhotoContent.js +6 -0
  122. package/lib/commonjs/models/FBSharePhotoContent.js.map +1 -0
  123. package/lib/commonjs/models/FBShareVideo.js +2 -0
  124. package/lib/commonjs/models/FBShareVideo.js.map +1 -0
  125. package/lib/commonjs/models/FBShareVideoContent.js +6 -0
  126. package/lib/commonjs/models/FBShareVideoContent.js.map +1 -0
  127. package/lib/commonjs/util/validate.js +180 -0
  128. package/lib/commonjs/util/validate.js.map +1 -0
  129. package/lib/commonjs/utils/index.js +2 -0
  130. package/lib/commonjs/utils/index.js.map +1 -0
  131. package/lib/module/FBAEMReporter.js +34 -0
  132. package/lib/module/FBAEMReporter.js.map +1 -0
  133. package/lib/module/FBAccessToken.js +191 -0
  134. package/lib/module/FBAccessToken.js.map +1 -0
  135. package/lib/module/FBAppEventsLogger.js +215 -0
  136. package/lib/module/FBAppEventsLogger.js.map +1 -0
  137. package/lib/module/FBAppLink.js +29 -0
  138. package/lib/module/FBAppLink.js.map +1 -0
  139. package/lib/module/FBAuthenticationToken.js +48 -0
  140. package/lib/module/FBAuthenticationToken.js.map +1 -0
  141. package/lib/module/FBGameRequestDialog.js +39 -0
  142. package/lib/module/FBGameRequestDialog.js.map +1 -0
  143. package/lib/module/FBGraphRequest.js +60 -0
  144. package/lib/module/FBGraphRequest.js.map +1 -0
  145. package/lib/module/FBGraphRequestManager.js +90 -0
  146. package/lib/module/FBGraphRequestManager.js.map +1 -0
  147. package/lib/module/FBLoginButton.js +62 -0
  148. package/lib/module/FBLoginButton.js.map +1 -0
  149. package/lib/module/FBLoginManager.js +97 -0
  150. package/lib/module/FBLoginManager.js.map +1 -0
  151. package/lib/module/FBMessageDialog.js +45 -0
  152. package/lib/module/FBMessageDialog.js.map +1 -0
  153. package/lib/module/FBProfile.js +127 -0
  154. package/lib/module/FBProfile.js.map +1 -0
  155. package/lib/module/FBSendButton.js +41 -0
  156. package/lib/module/FBSendButton.js.map +1 -0
  157. package/lib/module/FBSettings.js +108 -0
  158. package/lib/module/FBSettings.js.map +1 -0
  159. package/lib/module/FBShareButton.js +41 -0
  160. package/lib/module/FBShareButton.js.map +1 -0
  161. package/lib/module/FBShareDialog.js +51 -0
  162. package/lib/module/FBShareDialog.js.map +1 -0
  163. package/lib/module/index.js +44 -0
  164. package/lib/module/index.js.map +1 -0
  165. package/lib/module/models/FBAppGroupCreationContent.js +2 -0
  166. package/lib/module/models/FBAppGroupCreationContent.js.map +1 -0
  167. package/lib/module/models/FBGameRequestContent.js +2 -0
  168. package/lib/module/models/FBGameRequestContent.js.map +1 -0
  169. package/lib/module/models/FBSDKCallback.js +2 -0
  170. package/lib/module/models/FBSDKCallback.js.map +1 -0
  171. package/lib/module/models/FBShareContent.js +2 -0
  172. package/lib/module/models/FBShareContent.js.map +1 -0
  173. package/lib/module/models/FBShareLinkContent.js +2 -0
  174. package/lib/module/models/FBShareLinkContent.js.map +1 -0
  175. package/lib/module/models/FBSharePhoto.js +2 -0
  176. package/lib/module/models/FBSharePhoto.js.map +1 -0
  177. package/lib/module/models/FBSharePhotoContent.js +2 -0
  178. package/lib/module/models/FBSharePhotoContent.js.map +1 -0
  179. package/lib/module/models/FBShareVideo.js +2 -0
  180. package/lib/module/models/FBShareVideo.js.map +1 -0
  181. package/lib/module/models/FBShareVideoContent.js +2 -0
  182. package/lib/module/models/FBShareVideoContent.js.map +1 -0
  183. package/lib/module/util/validate.js +157 -0
  184. package/lib/module/util/validate.js.map +1 -0
  185. package/lib/module/utils/index.js +2 -0
  186. package/lib/module/utils/index.js.map +1 -0
  187. package/lib/typescript/FBAEMReporter.d.ts +21 -0
  188. package/lib/typescript/FBAEMReporter.d.ts.map +1 -0
  189. package/lib/typescript/FBAccessToken.d.ts +118 -0
  190. package/lib/typescript/FBAccessToken.d.ts.map +1 -0
  191. package/lib/typescript/FBAppEventsLogger.d.ts +201 -0
  192. package/lib/typescript/FBAppEventsLogger.d.ts.map +1 -0
  193. package/lib/typescript/FBAppLink.d.ts +5 -0
  194. package/lib/typescript/FBAppLink.d.ts.map +1 -0
  195. package/lib/typescript/FBAuthenticationToken.d.ts +29 -0
  196. package/lib/typescript/FBAuthenticationToken.d.ts.map +1 -0
  197. package/lib/typescript/FBGameRequestDialog.d.ts +39 -0
  198. package/lib/typescript/FBGameRequestDialog.d.ts.map +1 -0
  199. package/lib/typescript/FBGraphRequest.d.ts +70 -0
  200. package/lib/typescript/FBGraphRequest.d.ts.map +1 -0
  201. package/lib/typescript/FBGraphRequestManager.d.ts +51 -0
  202. package/lib/typescript/FBGraphRequestManager.d.ts.map +1 -0
  203. package/lib/typescript/FBLoginButton.d.ts +92 -0
  204. package/lib/typescript/FBLoginButton.d.ts.map +1 -0
  205. package/lib/typescript/FBLoginManager.d.ts +77 -0
  206. package/lib/typescript/FBLoginManager.d.ts.map +1 -0
  207. package/lib/typescript/FBMessageDialog.d.ts +42 -0
  208. package/lib/typescript/FBMessageDialog.d.ts.map +1 -0
  209. package/lib/typescript/FBProfile.d.ts +127 -0
  210. package/lib/typescript/FBProfile.d.ts.map +1 -0
  211. package/lib/typescript/FBSendButton.d.ts +42 -0
  212. package/lib/typescript/FBSendButton.d.ts.map +1 -0
  213. package/lib/typescript/FBSettings.d.ts +49 -0
  214. package/lib/typescript/FBSettings.d.ts.map +1 -0
  215. package/lib/typescript/FBShareButton.d.ts +42 -0
  216. package/lib/typescript/FBShareButton.d.ts.map +1 -0
  217. package/lib/typescript/FBShareDialog.d.ts +69 -0
  218. package/lib/typescript/FBShareDialog.d.ts.map +1 -0
  219. package/lib/typescript/index.d.ts +43 -0
  220. package/lib/typescript/index.d.ts.map +1 -0
  221. package/lib/typescript/models/FBAppGroupCreationContent.d.ts +43 -0
  222. package/lib/typescript/models/FBAppGroupCreationContent.d.ts.map +1 -0
  223. package/lib/typescript/models/FBGameRequestContent.d.ts +63 -0
  224. package/lib/typescript/models/FBGameRequestContent.d.ts.map +1 -0
  225. package/lib/typescript/models/FBSDKCallback.d.ts +4 -0
  226. package/lib/typescript/models/FBSDKCallback.d.ts.map +1 -0
  227. package/lib/typescript/models/FBShareContent.d.ts +48 -0
  228. package/lib/typescript/models/FBShareContent.d.ts.map +1 -0
  229. package/lib/typescript/models/FBShareLinkContent.d.ts +65 -0
  230. package/lib/typescript/models/FBShareLinkContent.d.ts.map +1 -0
  231. package/lib/typescript/models/FBSharePhoto.d.ts +43 -0
  232. package/lib/typescript/models/FBSharePhoto.d.ts.map +1 -0
  233. package/lib/typescript/models/FBSharePhotoContent.d.ts +45 -0
  234. package/lib/typescript/models/FBSharePhotoContent.d.ts.map +1 -0
  235. package/lib/typescript/models/FBShareVideo.d.ts +31 -0
  236. package/lib/typescript/models/FBShareVideo.d.ts.map +1 -0
  237. package/lib/typescript/models/FBShareVideoContent.d.ts +58 -0
  238. package/lib/typescript/models/FBShareVideoContent.d.ts.map +1 -0
  239. package/lib/typescript/util/validate.d.ts +62 -0
  240. package/lib/typescript/util/validate.d.ts.map +1 -0
  241. package/lib/typescript/utils/index.d.ts +2 -0
  242. package/lib/typescript/utils/index.d.ts.map +1 -0
  243. package/package.json +155 -0
  244. package/plugin/build/config.d.ts +53 -0
  245. package/plugin/build/config.js +46 -0
  246. package/plugin/build/withFacebook.d.ts +4 -0
  247. package/plugin/build/withFacebook.js +59 -0
  248. package/plugin/build/withFacebookAndroid.d.ts +6 -0
  249. package/plugin/build/withFacebookAndroid.js +197 -0
  250. package/plugin/build/withFacebookIOS.d.ts +15 -0
  251. package/plugin/build/withFacebookIOS.js +163 -0
  252. package/plugin/build/withSKAdNetworkIdentifiers.d.ts +9 -0
  253. package/plugin/build/withSKAdNetworkIdentifiers.js +36 -0
  254. package/plugin/tsconfig.json +9 -0
  255. package/react-native-fbsdk-next.podspec +34 -0
  256. package/src/FBAEMReporter.ts +44 -0
  257. package/src/FBAccessToken.ts +222 -0
  258. package/src/FBAppEventsLogger.ts +375 -0
  259. package/src/FBAppLink.ts +30 -0
  260. package/src/FBAuthenticationToken.ts +61 -0
  261. package/src/FBGameRequestDialog.ts +49 -0
  262. package/src/FBGraphRequest.ts +89 -0
  263. package/src/FBGraphRequestManager.ts +117 -0
  264. package/src/FBLoginButton.tsx +152 -0
  265. package/src/FBLoginManager.ts +133 -0
  266. package/src/FBMessageDialog.ts +53 -0
  267. package/src/FBProfile.ts +166 -0
  268. package/src/FBSendButton.tsx +61 -0
  269. package/src/FBSettings.ts +122 -0
  270. package/src/FBShareButton.tsx +61 -0
  271. package/src/FBShareDialog.ts +96 -0
  272. package/src/index.ts +85 -0
  273. package/src/models/FBAppGroupCreationContent.ts +48 -0
  274. package/src/models/FBGameRequestContent.ts +81 -0
  275. package/src/models/FBSDKCallback.ts +3 -0
  276. package/src/models/FBShareContent.ts +54 -0
  277. package/src/models/FBShareLinkContent.ts +71 -0
  278. package/src/models/FBSharePhoto.ts +45 -0
  279. package/src/models/FBSharePhotoContent.ts +48 -0
  280. package/src/models/FBShareVideo.ts +31 -0
  281. package/src/models/FBShareVideoContent.ts +64 -0
  282. package/src/util/validate.ts +167 -0
  283. package/src/utils/index.ts +1 -0
  284. package/tsconfig.json +103 -0
@@ -0,0 +1,49 @@
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
+ * @format
21
+ */
22
+ import {GameRequestContent} from './models/FBGameRequestContent';
23
+ import {RNFBSDKCallback} from './models/FBSDKCallback';
24
+ import {NativeModules} from 'react-native';
25
+
26
+ const GameRequestDialog = NativeModules.FBGameRequestDialog;
27
+
28
+ export type GameRequestDialogResult = RNFBSDKCallback & {
29
+ requestId: string;
30
+ to: Array<string>;
31
+ };
32
+
33
+ export default {
34
+ /**
35
+ * Check if the dialog can be shown.
36
+ */
37
+ canShow(): Promise<boolean> {
38
+ return GameRequestDialog.canShow();
39
+ },
40
+
41
+ /**
42
+ * Shows the dialog using the specified content.
43
+ */
44
+ show(
45
+ gameRequestContent: GameRequestContent,
46
+ ): Promise<GameRequestDialogResult> {
47
+ return GameRequestDialog.show(gameRequestContent);
48
+ },
49
+ };
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Copyright (c) 2015-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
+ * @format
21
+ */
22
+
23
+ export type GraphRequestCallback = (
24
+ error?: Record<string, unknown>,
25
+ result?: Record<string, unknown>,
26
+ ) => void;
27
+ export type GraphRequestConfig = {
28
+ /**
29
+ * The httpMethod to use for the request, for example "GET" or "POST".
30
+ */
31
+ httpMethod?: string;
32
+ /**
33
+ * The Graph API version to use (e.g., "v2.0")
34
+ */
35
+ version?: string;
36
+ /**
37
+ * The request parameters.
38
+ */
39
+ parameters?: GraphRequestParameters;
40
+ /**
41
+ * The access token used by the request.
42
+ */
43
+ accessToken?: string;
44
+ };
45
+ export type GraphRequestParameters = {[key: string]: unknown};
46
+
47
+ /**
48
+ * Represents a Graph API request and provides batch request supports.
49
+ */
50
+ class FBGraphRequest {
51
+ /**
52
+ * The Graph API endpoint to use for the request, for example "me".
53
+ */
54
+ graphPath: string;
55
+
56
+ /**
57
+ * The optional config for the request.
58
+ */
59
+ config: GraphRequestConfig;
60
+
61
+ /**
62
+ * Called upon completion or failure of the request.
63
+ */
64
+ callback: GraphRequestCallback;
65
+
66
+ /**
67
+ * Constructs a new Graph API request.
68
+ */
69
+ constructor(
70
+ graphPath: string,
71
+ config?: GraphRequestConfig,
72
+ callback?: GraphRequestCallback,
73
+ ) {
74
+ this.graphPath = graphPath;
75
+ this.config = config ? config : {};
76
+ this.callback = callback ? callback : () => null;
77
+ }
78
+
79
+ /**
80
+ * Adds a string parameter to the request.
81
+ */
82
+ addStringParameter(paramString: string, key: string) {
83
+ if (this.config != null && this.config.parameters != null) {
84
+ this.config.parameters[key] = {string: paramString};
85
+ }
86
+ }
87
+ }
88
+
89
+ export default FBGraphRequest;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Copyright (c) 2015-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
+ * @format
21
+ */
22
+ import GraphRequest, {GraphRequestParameters} from './FBGraphRequest';
23
+ import {NativeModules} from 'react-native';
24
+
25
+ const NativeGraphRequestManager = NativeModules.FBGraphRequest;
26
+
27
+ export type Callback = (
28
+ error?: Record<string, unknown>,
29
+ result?: Record<string, unknown>,
30
+ ) => void;
31
+
32
+ function _verifyParameters(request: GraphRequest) {
33
+ if (request.config?.parameters) {
34
+ for (const key in request.config.parameters) {
35
+ const param = request.config.parameters[key];
36
+
37
+ if (
38
+ typeof param === 'object' &&
39
+ (param as GraphRequestParameters)?.string
40
+ ) {
41
+ continue;
42
+ }
43
+ throw new Error(
44
+ "Unexpected value for parameter '" +
45
+ key +
46
+ "'. Request parameters " +
47
+ "need to be objects with a 'string' field.",
48
+ );
49
+ }
50
+ }
51
+ }
52
+
53
+ class FBGraphRequestManager {
54
+ requestBatch: Array<GraphRequest> = [];
55
+ requestCallbacks: Array<Callback | undefined> = [];
56
+ batchCallback: Callback | null = null;
57
+
58
+ /**
59
+ * Add a graph request.
60
+ */
61
+ addRequest(request: GraphRequest): FBGraphRequestManager {
62
+ _verifyParameters(request);
63
+ this.requestBatch.push(request);
64
+ this.requestCallbacks.push(request.callback);
65
+ return this;
66
+ }
67
+
68
+ /**
69
+ * Add call back to the GraphRequestManager. Only one callback can be added.
70
+ * Note that invocation of the batch callback does not indicate success of every
71
+ * graph request made, only that the entire batch has finished executing.
72
+ */
73
+ addBatchCallback(
74
+ callback: (
75
+ error?: Record<string, unknown>,
76
+ result?: Record<string, unknown>,
77
+ ) => void,
78
+ ): FBGraphRequestManager {
79
+ this.batchCallback = callback;
80
+ return this;
81
+ }
82
+
83
+ /**
84
+ * Executes requests in a batch.
85
+ * Note that when there's an issue with network connection the batch callback
86
+ * behavior differs in Android and iOS.
87
+ * On iOS, the batch callback returns an error if the batch fails with a network error.
88
+ * On Android, the batch callback always returns {"result": "batch finished executing"}
89
+ * after the batch time out. This is because detecting network status requires
90
+ * extra permission and it's unncessary for the sdk. Instead, you can use the NetInfo module
91
+ * in react-native to get the network status.
92
+ */
93
+ start(timeout?: number) {
94
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
95
+ const that = this;
96
+ const callback = (
97
+ error: Record<string, unknown>,
98
+ result: Record<string, unknown>,
99
+ response: Array<Array<Record<string, unknown>>>,
100
+ ) => {
101
+ if (response) {
102
+ that.requestCallbacks.forEach((innerCallback, index) => {
103
+ if (innerCallback) {
104
+ innerCallback(response[index][0], response[index][1]);
105
+ }
106
+ });
107
+ }
108
+ if (that.batchCallback) {
109
+ that.batchCallback(error, result);
110
+ }
111
+ };
112
+
113
+ NativeGraphRequestManager.start(this.requestBatch, timeout || 0, callback);
114
+ }
115
+ }
116
+
117
+ export default FBGraphRequestManager;
@@ -0,0 +1,152 @@
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
+ * @format
21
+ */
22
+ import {
23
+ DefaultAudience,
24
+ LoginBehaviorAndroid,
25
+ LoginResult,
26
+ LoginTracking,
27
+ } from './FBLoginManager';
28
+ import {PropsOf} from './utils';
29
+ import * as React from 'react';
30
+ import {requireNativeComponent, StyleSheet, ViewStyle} from 'react-native';
31
+
32
+ export type Event = {
33
+ nativeEvent?: {
34
+ type?: 'loginFinished' | 'logoutFinished';
35
+ error: Record<string, unknown>;
36
+ result: LoginResult;
37
+ };
38
+ };
39
+ export type TooltipBehaviorIOS = 'auto' | 'force_display' | 'disable';
40
+
41
+ /**
42
+ * A button that initiates a log in or log out flow upon tapping.
43
+ */
44
+ class LoginButton extends React.Component<{
45
+ /**
46
+ * Represents the permissions to request when the login button
47
+ * is pressed.
48
+ */
49
+ permissions?: Array<string>;
50
+
51
+ /**
52
+ * The callback invoked upon error/completion of a login request.
53
+ */
54
+ onLoginFinished?: (
55
+ error: Record<string, unknown>,
56
+ result: LoginResult,
57
+ ) => void;
58
+
59
+ /**
60
+ * The callback invoked upon completion of a logout request.
61
+ */
62
+ onLogoutFinished?: () => void;
63
+
64
+ /**
65
+ * The behavior to use when attempting a login.
66
+ * @platform android
67
+ */
68
+ loginBehaviorAndroid?: LoginBehaviorAndroid;
69
+
70
+ /**
71
+ * The default audience to target when attempting a login.
72
+ */
73
+ defaultAudience?: DefaultAudience;
74
+
75
+ /**
76
+ * For iOS only, the desired tooltip behavior.
77
+ * @platform ios
78
+ */
79
+ tooltipBehaviorIOS?: TooltipBehaviorIOS;
80
+
81
+ /**
82
+ * Gets or sets an optional nonce to use for login attempts. A valid nonce must be a non-empty string without
83
+ * whitespace. An invalid nonce will not be set. Instead, default unique nonces will be used for login attempts.
84
+ * @platform ios
85
+ */
86
+ nonceIOS?: string;
87
+
88
+ /**
89
+ * Gets or sets the desired tracking preference to use for login attempts. Defaults to `enabled`
90
+ * @platform ios
91
+ */
92
+ loginTrackingIOS?: LoginTracking;
93
+
94
+ /**
95
+ * View style, if any.
96
+ */
97
+ style?: ViewStyle;
98
+
99
+ /**
100
+ * testID, if any.
101
+ */
102
+ testID?: string;
103
+ }> {
104
+ static defaultProps: {
105
+ style: typeof styles.defaultButtonStyle;
106
+ };
107
+
108
+ _eventHandler(event: Event) {
109
+ if (typeof event !== 'object' || !event || !event.nativeEvent) {
110
+ return;
111
+ }
112
+ const eventDict = event.nativeEvent;
113
+ if (eventDict.type === 'loginFinished') {
114
+ if (this.props.onLoginFinished) {
115
+ this.props.onLoginFinished(eventDict.error, eventDict.result);
116
+ }
117
+ } else if (eventDict.type === 'logoutFinished') {
118
+ if (this.props.onLogoutFinished) {
119
+ this.props.onLogoutFinished();
120
+ }
121
+ }
122
+ }
123
+
124
+ render() {
125
+ return (
126
+ <RCTFBLoginButton
127
+ {...this.props}
128
+ onChange={this._eventHandler.bind(this)}
129
+ />
130
+ );
131
+ }
132
+ }
133
+
134
+ const styles = StyleSheet.create({
135
+ defaultButtonStyle: {
136
+ height: 30,
137
+ width: 190,
138
+ },
139
+ });
140
+
141
+ LoginButton.defaultProps = {
142
+ style: styles.defaultButtonStyle,
143
+ };
144
+
145
+ type RCTFBLoginButtonProps = PropsOf<LoginButton> & {
146
+ onChange: (event: Event) => void;
147
+ };
148
+
149
+ const RCTFBLoginButton =
150
+ requireNativeComponent<RCTFBLoginButtonProps>('RCTFBLoginButton');
151
+
152
+ export default LoginButton;
@@ -0,0 +1,133 @@
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
+ * @format
21
+ */
22
+ import {RNFBSDKCallback} from './models/FBSDKCallback';
23
+ import {NativeModules, Platform} from 'react-native';
24
+
25
+ const LoginManager = NativeModules.FBLoginManager;
26
+ /**
27
+ * Indicates which default audience to use for sessions that post data to Facebook.
28
+ */
29
+ export type DefaultAudience =
30
+ // Indicates that the user's friends are able to see posts made by the application.
31
+ | 'friends'
32
+ // Indicates that all Facebook users are able to see posts made by the application.
33
+ | 'everyone'
34
+ // Indicates that only the user is able to see posts made by the application.
35
+ | 'only_me';
36
+ export type LoginBehavior = LoginBehaviorIOS | LoginBehaviorAndroid;
37
+ /**
38
+ * Indicate how Facebook Login should be attempted on Android.
39
+ */
40
+ export type LoginBehaviorAndroid =
41
+ // Attempt login in using the Facebook App, and if that does not work fall back to web dialog auth.
42
+ | 'native_with_fallback'
43
+ // Only attempt to login using the Facebook App.
44
+ | 'native_only'
45
+ // Only the web dialog auth should be used.
46
+ | 'web_only';
47
+ /**
48
+ * Indicate how Facebook Login should be attempted on iOS.
49
+ */
50
+ export type LoginBehaviorIOS =
51
+ // Attempts log in through the Safari browser.
52
+ // This is the only behavior supported by the native sdk.
53
+ 'browser';
54
+ /**
55
+ * Shows the results of a login operation.
56
+ */
57
+ export type LoginResult = RNFBSDKCallback & {
58
+ grantedPermissions?: Array<string>;
59
+ declinedPermissions?: Array<string>;
60
+ };
61
+
62
+ export type LoginTracking = 'enabled' | 'limited';
63
+
64
+ export default {
65
+ /**
66
+ * Log in with the requested permissions.
67
+ * @param loginTrackingIOS IOS only: loginTracking: 'enabled' | 'limited', default 'enabled'.
68
+ * @param nonceIOS IOS only: Nonce that the configuration was created with. A unique nonce will be used if none is provided to the factory method.
69
+ */
70
+ logInWithPermissions(
71
+ permissions: Array<string>,
72
+ loginTrackingIOS?: LoginTracking,
73
+ nonceIOS?: string,
74
+ ): Promise<LoginResult> {
75
+ if (Platform.OS === 'ios') {
76
+ return LoginManager.logInWithPermissions(
77
+ permissions,
78
+ loginTrackingIOS,
79
+ nonceIOS,
80
+ );
81
+ }
82
+ return LoginManager.logInWithPermissions(permissions);
83
+ },
84
+
85
+ /**
86
+ * Getter for the login behavior.
87
+ */
88
+ getLoginBehavior(): Promise<LoginBehavior> {
89
+ if (Platform.OS === 'ios') {
90
+ return Promise.resolve('browser');
91
+ } else {
92
+ return LoginManager.getLoginBehavior();
93
+ }
94
+ },
95
+
96
+ /**
97
+ * Setter for the login behavior.
98
+ */
99
+ setLoginBehavior(loginBehavior: LoginBehavior) {
100
+ if (Platform.OS === 'ios') {
101
+ return;
102
+ }
103
+ LoginManager.setLoginBehavior(loginBehavior);
104
+ },
105
+
106
+ /**
107
+ * Getter for the default audience.
108
+ */
109
+ getDefaultAudience(): Promise<DefaultAudience> {
110
+ return LoginManager.getDefaultAudience();
111
+ },
112
+
113
+ /**
114
+ * Setter for the default audience.
115
+ */
116
+ setDefaultAudience(defaultAudience: DefaultAudience) {
117
+ LoginManager.setDefaultAudience(defaultAudience);
118
+ },
119
+
120
+ /**
121
+ * Re-authorizes the user to update data access permissions.
122
+ */
123
+ reauthorizeDataAccess(): Promise<LoginResult> {
124
+ return LoginManager.reauthorizeDataAccess();
125
+ },
126
+
127
+ /**
128
+ * Logs out the user.
129
+ */
130
+ logOut() {
131
+ LoginManager.logOut();
132
+ },
133
+ };
@@ -0,0 +1,53 @@
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
+ * @format
21
+ */
22
+ import {RNFBSDKCallback} from './models/FBSDKCallback';
23
+ import {ShareContent} from './models/FBShareContent';
24
+ import {NativeModules} from 'react-native';
25
+
26
+ const MessageDialog = NativeModules.FBMessageDialog;
27
+
28
+ export type MessageDialogResult = RNFBSDKCallback & {
29
+ postId: string;
30
+ };
31
+
32
+ export default {
33
+ /**
34
+ * Check if the dialog can be shown.
35
+ */
36
+ canShow(shareContent: ShareContent): Promise<boolean> {
37
+ return MessageDialog.canShow(shareContent);
38
+ },
39
+
40
+ /**
41
+ * Shows the dialog using the specified content.
42
+ */
43
+ show(shareContent: ShareContent): Promise<MessageDialogResult> {
44
+ return MessageDialog.show(shareContent);
45
+ },
46
+
47
+ /**
48
+ * Sets whether or not the native message dialog should fail when it encounters a data error.
49
+ */
50
+ setShouldFailOnDataError(shouldFailOnDataError: boolean) {
51
+ MessageDialog.setShouldFailOnDataError(shouldFailOnDataError);
52
+ },
53
+ };