@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,222 @@
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 {NativeModules, NativeEventEmitter} from 'react-native';
23
+
24
+ const AccessToken = NativeModules.FBAccessToken;
25
+
26
+ const eventEmitter = new NativeEventEmitter(AccessToken);
27
+
28
+ export type AccessTokenMap = {
29
+ accessToken: string;
30
+ permissions: Array<string>;
31
+ declinedPermissions: Array<string>;
32
+ expiredPermissions: Array<string>;
33
+ applicationID: string;
34
+ userID: string;
35
+ expirationTime: number;
36
+ lastRefreshTime: number;
37
+ dataAccessExpirationTime: number;
38
+ accessTokenSource?: string;
39
+ };
40
+
41
+ /**
42
+ * Represents an immutable access token for using Facebook services.
43
+ */
44
+ class FBAccessToken {
45
+ /**
46
+ * The access token string.
47
+ */
48
+ accessToken: string;
49
+
50
+ /**
51
+ * The known granted permissions.
52
+ */
53
+ permissions: Array<string>;
54
+
55
+ /**
56
+ * The known declined permissions.
57
+ */
58
+ declinedPermissions: Array<string>;
59
+
60
+ /**
61
+ * The known expired permissions.
62
+ */
63
+ expiredPermissions: Array<string>;
64
+
65
+ /**
66
+ * The app ID.
67
+ */
68
+ applicationID: string;
69
+
70
+ /**
71
+ * The user ID.
72
+ */
73
+ userID: string;
74
+
75
+ /**
76
+ * The expiration time of the access token.
77
+ * The value is the number of milliseconds since Jan. 1, 1970, midnight GMT.
78
+ */
79
+ expirationTime: number;
80
+
81
+ /**
82
+ * The last refresh time of the access token.
83
+ * The value is the number of milliseconds since Jan. 1, 1970, midnight GMT.
84
+ */
85
+ lastRefreshTime: number;
86
+
87
+ /**
88
+ * The data access expiration time of the access token.
89
+ * The value is the number of milliseconds since Jan. 1, 1970, midnight GMT.
90
+ */
91
+ dataAccessExpirationTime: number;
92
+
93
+ /**
94
+ * The source of access token.
95
+ * @platform android
96
+ */
97
+ accessTokenSource?: string;
98
+
99
+ constructor(tokenMap: AccessTokenMap) {
100
+ this.accessToken = tokenMap.accessToken;
101
+ this.permissions = tokenMap.permissions;
102
+ this.declinedPermissions = tokenMap.declinedPermissions;
103
+ this.expiredPermissions = tokenMap.expiredPermissions;
104
+ this.applicationID = tokenMap.applicationID;
105
+ this.userID = tokenMap.userID;
106
+ this.expirationTime = tokenMap.expirationTime;
107
+ this.lastRefreshTime = tokenMap.lastRefreshTime;
108
+ this.dataAccessExpirationTime = tokenMap.dataAccessExpirationTime;
109
+ this.accessTokenSource = tokenMap.accessTokenSource;
110
+ Object.freeze(this);
111
+ }
112
+
113
+ /**
114
+ * Getter for the access token that is current for the application.
115
+ */
116
+ static getCurrentAccessToken() {
117
+ return new Promise<FBAccessToken | null>((resolve) => {
118
+ AccessToken.getCurrentAccessToken((tokenMap?: AccessTokenMap) => {
119
+ if (tokenMap) {
120
+ resolve(new FBAccessToken(tokenMap));
121
+ } else {
122
+ resolve(null);
123
+ }
124
+ });
125
+ });
126
+ }
127
+
128
+ /**
129
+ * Setter for the access token that is current for the application.
130
+ */
131
+ static setCurrentAccessToken(accessToken: AccessTokenMap) {
132
+ AccessToken.setCurrentAccessToken(accessToken);
133
+ }
134
+
135
+ /**
136
+ * Updates the current access token with up to date permissions,
137
+ * and extends the expiration date, if extension is possible.
138
+ */
139
+ static refreshCurrentAccessTokenAsync(): Promise<AccessTokenMap> {
140
+ return AccessToken.refreshCurrentAccessTokenAsync();
141
+ }
142
+
143
+ /**
144
+ * Adds a listener for when the access token changes. Returns a functions which removes the
145
+ * listener when called.
146
+ */
147
+ static addListener(listener: (accessToken: FBAccessToken | null) => void) {
148
+ const subscription = eventEmitter.addListener(
149
+ 'fbsdk.accessTokenDidChange',
150
+ (tokenMap: AccessTokenMap) => {
151
+ if (tokenMap) {
152
+ listener(new FBAccessToken(tokenMap));
153
+ } else {
154
+ listener(null);
155
+ }
156
+ },
157
+ );
158
+ return () => subscription.remove();
159
+ }
160
+
161
+ /**
162
+ * Gets the date at which the access token expires. The value is the number of
163
+ * milliseconds since Jan. 1, 1970, midnight GMT.
164
+ */
165
+ getExpires() {
166
+ return this.expirationTime;
167
+ }
168
+
169
+ /**
170
+ * Get the list of permissions associated with this access token. Note that the most up-to-date
171
+ * list of permissions is maintained by Facebook, so this list may be outdated if permissions
172
+ * have been added or removed since the time the AccessToken object was created. See
173
+ * https://developers.facebook.com/docs/reference/login/#permissions for details.
174
+ */
175
+ getPermissions() {
176
+ return this.permissions;
177
+ }
178
+
179
+ /**
180
+ * Gets the list of permissions declined by the user with this access token. It represents the
181
+ * entire set of permissions that have been requested and declined. Note that the most
182
+ * up-to-date list of permissions is maintained by Facebook, so this list may be outdated if
183
+ * permissions have been granted or declined since the last time an AccessToken object was
184
+ * created. See https://developers.facebook.com/docs/reference/login/#permissions for details.
185
+ */
186
+ getDeclinedPermissions() {
187
+ return this.declinedPermissions;
188
+ }
189
+
190
+ getExpiredPermissions() {
191
+ return this.expiredPermissions;
192
+ }
193
+
194
+ /**
195
+ * Gets the date at which the token was last refreshed. Since tokens expire, the Facebook SDK
196
+ * will attempt to renew them periodically. The value is the number of milliseconds since
197
+ * Jan. 1, 1970, midnight GMT.
198
+ */
199
+ getLastRefresh() {
200
+ return this.lastRefreshTime;
201
+ }
202
+
203
+ getDataAccessExpiration() {
204
+ return this.dataAccessExpirationTime;
205
+ }
206
+
207
+ /**
208
+ * Gets the ID of the Facebook Application associated with this access token.
209
+ */
210
+ getApplicationId() {
211
+ return this.applicationID;
212
+ }
213
+
214
+ /**
215
+ * Gets user ID associated with this access token.
216
+ */
217
+ getUserId() {
218
+ return this.userID;
219
+ }
220
+ }
221
+
222
+ export default FBAccessToken;
@@ -0,0 +1,375 @@
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 {isDefined, isNumber, isOneOf, isString} from './util/validate';
23
+ import {NativeModules} from 'react-native';
24
+ import {Platform} from 'react-native';
25
+
26
+ const AppEventsLogger = NativeModules.FBAppEventsLogger;
27
+
28
+ /**
29
+ * Controls when an AppEventsLogger sends log events to the server
30
+ */
31
+ export type AppEventsFlushBehavior =
32
+ /**
33
+ * Flush automatically: periodically (every 15 seconds or after every 100 events), and
34
+ * always at app reactivation. This is the default value.
35
+ */
36
+ | 'auto'
37
+ /**
38
+ * Only flush when AppEventsLogger.flush() is explicitly invoked.
39
+ */
40
+ | 'explicit_only';
41
+
42
+ /**
43
+ * Specifies product availability for Product Catalog product item update
44
+ */
45
+ export type ProductAvailability =
46
+ /**
47
+ * Item ships immediately
48
+ */
49
+ | 'in_stock'
50
+ /**
51
+ * No plan to restock
52
+ */
53
+ | 'out_of_stock'
54
+ /**
55
+ * Available in future
56
+ */
57
+ | 'preorder'
58
+ /**
59
+ * Ships in 1-2 weeks
60
+ */
61
+ | 'avaliable_for_order'
62
+ /**
63
+ * Discontinued
64
+ */
65
+ | 'discontinued';
66
+
67
+ /**
68
+ * Specifies product condition for Product Catalog product item update
69
+ */
70
+ export type ProductCondition = 'new' | 'refurbished' | 'used';
71
+
72
+ export type Params = {[key: string]: string | number};
73
+
74
+ /**
75
+ * Info about a user to increase chances of matching a Facebook user.
76
+ * See https://developers.facebook.com/docs/app-events/advanced-matching for
77
+ * more info about the expected format of each field.
78
+ */
79
+ export type UserData = Readonly<{
80
+ email?: string;
81
+ firstName?: string;
82
+ lastName?: string;
83
+ phone?: string;
84
+ dateOfBirth?: string;
85
+ gender?: 'm' | 'f';
86
+ city?: string;
87
+ state?: string;
88
+ zip?: string;
89
+ country?: string;
90
+ }>;
91
+
92
+ export type AppEvent = {
93
+ AchievedLevel: string;
94
+ AdClick: string;
95
+ AdImpression: string;
96
+ AddedPaymentInfo: string;
97
+ AddedToCart: string;
98
+ AddedToWishlist: string;
99
+ CompletedRegistration: string;
100
+ CompletedTutorial: string;
101
+ Contact: string;
102
+ CustomizeProduct: string;
103
+ Donate: string;
104
+ FindLocation: string;
105
+ InitiatedCheckout: string;
106
+ Purchased: string;
107
+ Rated: string;
108
+ Searched: string;
109
+ SpentCredits: string;
110
+ Schedule: string;
111
+ StartTrial: string;
112
+ SubmitApplication: string;
113
+ Subscribe: string;
114
+ UnlockedAchievement: string;
115
+ ViewedContent: string;
116
+ };
117
+
118
+ export type AppEventParam = {
119
+ AddType: string;
120
+ Content: string;
121
+ ContentID: string;
122
+ ContentType: string;
123
+ Currency: string;
124
+ Description: string;
125
+ Level: string;
126
+ NumItems: string;
127
+ MaxRatingValue: string;
128
+ OrderId: string;
129
+ PaymentInfoAvailable: string;
130
+ RegistrationMethod: string;
131
+ SearchString: string;
132
+ Success: string;
133
+ ValueNo: string;
134
+ ValueYes: string;
135
+ };
136
+
137
+ const {
138
+ AppEvents,
139
+ AppEventParams,
140
+ }: {AppEvents: AppEvent; AppEventParams: AppEventParam} =
141
+ AppEventsLogger?.getConstants() || {};
142
+
143
+ export default {
144
+ /**
145
+ * Sets the current event flushing behavior specifying when events
146
+ * are sent back to Facebook servers.
147
+ */
148
+ setFlushBehavior(flushBehavior: AppEventsFlushBehavior) {
149
+ AppEventsLogger.setFlushBehavior(flushBehavior);
150
+ },
151
+
152
+ /**
153
+ * Logs an event with eventName and optional arguments.
154
+ * This function supports the following usage:
155
+ * logEvent(eventName: string);
156
+ * logEvent(eventName: string, valueToSum: number);
157
+ * logEvent(eventName: string, parameters: {[key:string]:string|number});
158
+ * logEvent(eventName: string, valueToSum: number, parameters: {[key:string]:string|number});
159
+ * See https://developers.facebook.com/docs/app-events/android for detail.
160
+ */
161
+ logEvent(eventName: string, ...args: Array<number | Params>) {
162
+ let valueToSum = 0;
163
+ if (typeof args[0] === 'number') {
164
+ valueToSum = Number(args.shift());
165
+ }
166
+ let parameters = null;
167
+ if (typeof args[0] === 'object') {
168
+ parameters = args[0];
169
+ }
170
+ AppEventsLogger.logEvent(eventName, valueToSum, parameters);
171
+ },
172
+
173
+ /**
174
+ * Logs a purchase. See http://en.wikipedia.org/wiki/ISO_4217 for currencyCode.
175
+ */
176
+ logPurchase(
177
+ purchaseAmount: number,
178
+ currencyCode: string,
179
+ parameters?: Params,
180
+ ) {
181
+ AppEventsLogger.logPurchase(purchaseAmount, currencyCode, parameters);
182
+ },
183
+
184
+ /**
185
+ * Logs an app event that tracks that the application was open via Push Notification.
186
+ */
187
+ logPushNotificationOpen(payload?: Record<string, string | number>) {
188
+ AppEventsLogger.logPushNotificationOpen(payload);
189
+ },
190
+
191
+ /**
192
+ * Uploads product catalog product item as an app event
193
+ * @param itemID – Unique ID for the item. Can be a variant for a product. Max size is 100.
194
+ * @param availability – If item is in stock. Accepted values are: in stock - Item ships immediately out of stock - No plan to restock preorder - Available in future available for order - Ships in 1-2 weeks discontinued - Discontinued
195
+ * @param condition – Product condition: new, refurbished or used.
196
+ * @param description – Short text describing product. Max size is 5000.
197
+ * @param imageLink – Link to item image used in ad.
198
+ * @param link – Link to merchant's site where someone can buy the item.
199
+ * @param title – Title of item.
200
+ * @param priceAmount – Amount of purchase, in the currency specified by the 'currency' parameter. This value will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
201
+ * @param currency – Currency used to specify the amount.
202
+ * @param gtin – Global Trade Item Number including UPC, EAN, JAN and ISBN
203
+ * @param mpn – Unique manufacture ID for product
204
+ * @param brand – Name of the brand Note: Either gtin, mpn or brand is required.
205
+ * @param parameters – Optional fields for deep link specification.
206
+ */
207
+ logProductItem(
208
+ itemID: string,
209
+ availability: ProductAvailability,
210
+ condition: ProductCondition,
211
+ description: string,
212
+ imageLink: string,
213
+ link: string,
214
+ title: string,
215
+ priceAmount: number,
216
+ currency: string,
217
+ gtin?: string,
218
+ mpn?: string,
219
+ brand?: string,
220
+ parameters?: Params,
221
+ ) {
222
+ if (!isDefined(itemID) || !isString(itemID)) {
223
+ throw new Error("logProductItem expected 'itemID' to be a string");
224
+ }
225
+ if (
226
+ !isDefined(availability) ||
227
+ !isOneOf(availability, [
228
+ 'in_stock',
229
+ 'out_of_stock',
230
+ 'preorder',
231
+ 'avaliable_for_order',
232
+ 'discontinued',
233
+ ])
234
+ ) {
235
+ throw new Error(
236
+ "logProductItem expected 'availability' to be one of 'in_stock' | 'out_of_stock' | 'preorder' | 'avaliable_for_order' | 'discontinued'",
237
+ );
238
+ }
239
+ if (
240
+ !isDefined(condition) ||
241
+ !isOneOf(condition, ['new', 'refurbished', 'used'])
242
+ ) {
243
+ throw new Error(
244
+ "logProductItem expected 'condition' to be one of 'new' | 'refurbished' | 'used'",
245
+ );
246
+ }
247
+ if (!isDefined(description) || !isString(description)) {
248
+ throw new Error("logProductItem expected 'description' to be a string");
249
+ }
250
+ if (!isDefined(imageLink) || !isString(imageLink)) {
251
+ throw new Error("logProductItem expected 'imageLink' to be a string");
252
+ }
253
+ if (!isDefined(link) || !isString(link)) {
254
+ throw new Error("logProductItem expected 'link' to be a string");
255
+ }
256
+ if (!isDefined(title) || !isString(title)) {
257
+ throw new Error("logProductItem expected 'title' to be a string");
258
+ }
259
+ if (!isDefined(priceAmount) || !isNumber(priceAmount)) {
260
+ throw new Error("logProductItem expected 'priceAmount' to be a number");
261
+ }
262
+ if (!isDefined(currency) || !isString(currency)) {
263
+ throw new Error("logProductItem expected 'currency' to be a string");
264
+ }
265
+ if (!isDefined(gtin) && !isDefined(mpn) && !isDefined(brand)) {
266
+ throw new Error(
267
+ 'logProductItem expected either gtin, mpn or brand to be defined',
268
+ );
269
+ }
270
+
271
+ AppEventsLogger.logProductItem(
272
+ itemID,
273
+ availability,
274
+ condition,
275
+ description,
276
+ imageLink,
277
+ link,
278
+ title,
279
+ priceAmount,
280
+ currency,
281
+ gtin,
282
+ mpn,
283
+ brand,
284
+ parameters,
285
+ );
286
+ },
287
+
288
+ /**
289
+ * Explicitly kicks off flushing of events to Facebook.
290
+ */
291
+ flush() {
292
+ AppEventsLogger.flush();
293
+ },
294
+
295
+ /**
296
+ * Sets a custom user ID to associate with all app events.
297
+ * The userID is persisted until this method is called again with a null userId
298
+ */
299
+ setUserID(userID: string | null) {
300
+ AppEventsLogger.setUserID(userID);
301
+ },
302
+
303
+ /**
304
+ * Clears the currently set user id.
305
+ * @deprecated use setUserID(null) instead
306
+ */
307
+ clearUserID() {
308
+ AppEventsLogger.clearUserID();
309
+ },
310
+
311
+ /**
312
+ * Returns user id or null if not set
313
+ */
314
+ async getUserID(): Promise<string | null> {
315
+ return await AppEventsLogger.getUserID();
316
+ },
317
+
318
+ /**
319
+ * Returns anonymous id or null if not set
320
+ */
321
+ async getAnonymousID(): Promise<string | null> {
322
+ return await AppEventsLogger.getAnonymousID();
323
+ },
324
+
325
+ /**
326
+ * Returns advertiser id or null if not set
327
+ */
328
+ async getAdvertiserID(): Promise<string | null> {
329
+ return await AppEventsLogger.getAdvertiserID();
330
+ },
331
+
332
+ /**
333
+ * Returns advertiser id or null if not set.
334
+ * @platform android
335
+ */
336
+ async getAttributionID(): Promise<string | null> {
337
+ if (Platform.OS === 'ios') {
338
+ return null;
339
+ }
340
+ return await AppEventsLogger.getAttributionID();
341
+ },
342
+
343
+ /**
344
+ * Set additional data about the user to increase chances of matching a Facebook user.
345
+ */
346
+ setUserData(userData: UserData) {
347
+ AppEventsLogger.setUserData(userData);
348
+ },
349
+
350
+ /**
351
+ * For iOS only, sets and sends device token to register the current application for push notifications.
352
+ * @platform ios
353
+ */
354
+ setPushNotificationsDeviceToken(deviceToken: string) {
355
+ AppEventsLogger.setPushNotificationsDeviceToken(deviceToken);
356
+ },
357
+
358
+ /**
359
+ * For Android only, sets and sends registration id to register the current app for push notifications.
360
+ * @platform Android
361
+ */
362
+ setPushNotificationsRegistrationId(registrationId: string) {
363
+ AppEventsLogger.setPushNotificationsRegistrationId(registrationId);
364
+ },
365
+
366
+ /**
367
+ * Predefined event names for logging events common to many apps.
368
+ */
369
+ AppEvents,
370
+
371
+ /**
372
+ * Predefined event name parameters for common additional information to accompany events logged through the `logEvent`.
373
+ */
374
+ AppEventParams,
375
+ };
@@ -0,0 +1,30 @@
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 {NativeModules} from 'react-native';
23
+
24
+ const AppLink = NativeModules.FBAppLink;
25
+
26
+ export default {
27
+ fetchDeferredAppLink(): Promise<string | null> {
28
+ return AppLink.fetchDeferredAppLink();
29
+ },
30
+ };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @format
3
+ */
4
+ import {Platform, NativeModules} from 'react-native';
5
+
6
+ const AuthenticationToken = NativeModules.FBAuthenticationToken;
7
+
8
+ export type AuthenticationTokenMap = {
9
+ authenticationToken: string;
10
+ nonce: string;
11
+ graphDomain: string;
12
+ };
13
+
14
+ /**
15
+ * Represents an immutable access token for using Facebook services.
16
+ */
17
+ class FBAuthenticationToken {
18
+ /**
19
+ The raw token string from the authentication response
20
+ */
21
+ authenticationToken: string;
22
+
23
+ /**
24
+ The nonce from the decoded authentication response
25
+ */
26
+ nonce: string;
27
+
28
+ /**
29
+ The graph domain where the user is authenticated.
30
+ */
31
+ graphDomain: string;
32
+
33
+ constructor(tokenMap: AuthenticationTokenMap) {
34
+ this.authenticationToken = tokenMap.authenticationToken;
35
+ this.nonce = tokenMap.nonce;
36
+ this.graphDomain = tokenMap.graphDomain;
37
+ Object.freeze(this);
38
+ }
39
+
40
+ /**
41
+ * Getter for the authentication token
42
+ */
43
+ static getAuthenticationTokenIOS() {
44
+ if (Platform.OS === 'android') {
45
+ return Promise.resolve(null);
46
+ }
47
+ return new Promise<FBAuthenticationToken | null>((resolve) => {
48
+ AuthenticationToken.getAuthenticationToken(
49
+ (tokenMap: AuthenticationTokenMap) => {
50
+ if (tokenMap) {
51
+ resolve(new FBAuthenticationToken(tokenMap));
52
+ } else {
53
+ resolve(null);
54
+ }
55
+ },
56
+ );
57
+ });
58
+ }
59
+ }
60
+
61
+ export default FBAuthenticationToken;