@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,414 @@
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 android.os.Bundle;
24
+
25
+ import androidx.annotation.Nullable;
26
+
27
+ import com.facebook.appevents.AppEventsConstants;
28
+ import com.facebook.appevents.AppEventsLogger;
29
+ import com.facebook.internal.AttributionIdentifiers;
30
+ import com.facebook.react.bridge.Arguments;
31
+ import com.facebook.react.bridge.Promise;
32
+ import com.facebook.react.bridge.ReactApplicationContext;
33
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
34
+ import com.facebook.react.bridge.ReactMethod;
35
+ import com.facebook.react.bridge.ReadableMap;
36
+ import com.facebook.react.module.annotations.ReactModule;
37
+
38
+ import java.math.BigDecimal;
39
+ import java.util.Currency;
40
+ import java.util.HashMap;
41
+ import java.util.Locale;
42
+ import java.util.Map;
43
+
44
+ /**
45
+ * <p>
46
+ * This class allows the developer to log various types of events back to Facebook.
47
+ * </p>
48
+ * <p>
49
+ * This client-side event logging is then available through Facebook App Insights
50
+ * and for use with Facebook Ads conversion tracking and optimization.
51
+ * </p>
52
+ * <p>
53
+ * The class has a few related roles:
54
+ * </p>
55
+ * <ul>
56
+ * <li>
57
+ * Logging predefined and application-defined events to Facebook App Insights with a
58
+ * numeric value to sum across a large number of events, and an optional set of key/value
59
+ * parameters that define "segments" for this event (e.g., 'purchaserStatus' : 'frequent', or
60
+ * 'gamerLevel' : 'intermediate'). These events may also be used for ads conversion tracking,
61
+ * optimization, and other ads related targeting in the future.
62
+ * </li>
63
+ * <li>
64
+ * Methods that control the way in which events are flushed out to the Facebook servers.
65
+ * </li>
66
+ * </ul>
67
+ * <p>
68
+ * Here are some important characteristics of the logging mechanism:
69
+ * <ul>
70
+ * <li>
71
+ * Events are not sent immediately when logged. They're cached and flushed out to the
72
+ * Facebook servers in a number of situations:
73
+ * <ul>
74
+ * <li>when an event count threshold is passed (currently 100 logged events).</li>
75
+ * <li>when a time threshold is passed (currently 15 seconds).</li>
76
+ * <li>when an app has gone to background and is then brought back to the foreground.</li>
77
+ * </ul>
78
+ * <li>
79
+ * Events will be accumulated when the app is in a disconnected state, and sent when the connection
80
+ * is restored and one of the above 'flush' conditions are met.
81
+ * </li>
82
+ * <li>
83
+ * The class is intended to be used from the thread it was created on. Multiple
84
+ * AppEventsLoggers may be created on other threads if desired.
85
+ * </li>
86
+ * <li>
87
+ * The developer can call the setFlushBehavior method to force the flushing of events to only
88
+ * occur on an explicit call to the `flush` method.
89
+ * </li>
90
+ * </ul>
91
+ * </p>
92
+ * <p>
93
+ * Some things to note when logging events:
94
+ * <ul>
95
+ * <li>
96
+ * There is a limit on the number of unique event names an app can use, on the order of 1000.
97
+ * </li>
98
+ * <li>
99
+ * There is a limit to the number of unique parameter names in the provided parameters that can
100
+ * be used per event, on the order of 25. This is not just for an individual call, but for all
101
+ * invocations for that eventName.
102
+ * </li>
103
+ * <li>
104
+ * Event names and parameter names must be between 2 and 40
105
+ * characters, and must consist of alphanumeric characters, _, -, or spaces.
106
+ * </li>
107
+ * <li>
108
+ * The length of each parameter value can be no more than on the order of 100 characters.
109
+ * </li>
110
+ * </ul>
111
+ * </p>
112
+ */
113
+ @ReactModule(name = FBAppEventsLoggerModule.NAME)
114
+ public class FBAppEventsLoggerModule extends ReactContextBaseJavaModule {
115
+
116
+ public static final String NAME = "FBAppEventsLogger";
117
+
118
+ private AppEventsLogger mAppEventLogger;
119
+ private AttributionIdentifiers mAttributionIdentifiers;
120
+ private ReactApplicationContext mReactContext;
121
+
122
+ public FBAppEventsLoggerModule(ReactApplicationContext reactContext) {
123
+ super(reactContext);
124
+ mReactContext = reactContext;
125
+ }
126
+
127
+ @Override
128
+ public void initialize() {
129
+ mAppEventLogger = AppEventsLogger.newLogger(mReactContext);
130
+ mAttributionIdentifiers = AttributionIdentifiers.getAttributionIdentifiers(mReactContext);
131
+ }
132
+
133
+ @Override
134
+ public String getName() {
135
+ return NAME;
136
+ }
137
+
138
+ /**
139
+ * Set the behavior that this AppEventsLogger uses to determine when to flush logged events to
140
+ * the server. This setting applies to all instances of AppEventsLogger.
141
+ * @param flushBehavior the desired behavior.
142
+ */
143
+ @ReactMethod
144
+ public void setFlushBehavior(String flushBehavior) {
145
+ AppEventsLogger.setFlushBehavior(AppEventsLogger.FlushBehavior.valueOf(flushBehavior.toUpperCase(Locale.ROOT)));
146
+ }
147
+
148
+ /**
149
+ * Log an app event with the specified name.
150
+ * @param eventName eventName used to denote the event. Choose amongst the EVENT_NAME_*
151
+ * constants in {@link AppEventsConstants} when possible. Or create your own
152
+ * if none of the EVENT_NAME_* constants are applicable. Event names should be
153
+ * 40 characters or less, alphanumeric, and can include spaces, underscores or
154
+ * hyphens, but must not have a space or hyphen as the first character. Any
155
+ * given app should have no more than 1000 distinct event names.
156
+ * @param valueToSum a value to associate with the event which will be summed up in Insights for
157
+ * across all instances of the event, so that average values can be
158
+ * determined, etc.
159
+ * @param parameters Parameters to log with the event. Insights will allow looking
160
+ * at the logs of these events via different parameter values. You can log on
161
+ * the order of 25 parameters with each distinct eventName. It's advisable to
162
+ * limit the number of unique values provided for each parameter in the
163
+ * thousands. As an example, don't attempt to provide a unique
164
+ * parameter value for each unique user in your app. You won't get meaningful
165
+ * aggregate reporting on so many parameter values. The values in the bundles
166
+ * should be Strings or numeric values.
167
+ */
168
+ @ReactMethod
169
+ public void logEvent(String eventName, double valueToSum, ReadableMap parameters) {
170
+ mAppEventLogger.logEvent(eventName, valueToSum, Arguments.toBundle(parameters));
171
+ }
172
+
173
+ /**
174
+ * Logs a purchase event with Facebook, in the specified amount and with the specified
175
+ * currency.
176
+ * @param purchaseAmount Amount of purchase, in the currency specified by the 'currencyCode'
177
+ * parameter. This value will be rounded to the thousandths place (e.g.,
178
+ * 12.34567 becomes 12.346).
179
+ * @param currencyCode A currency corresponding to an
180
+ * <a href="http://en.wikipedia.org/wiki/ISO_4217">ISO 4217</a>
181
+ * currency code such as "EUR" or "USD".
182
+ * @param parameters Arbitrary additional information for describing this event. This should
183
+ * have no more than 24 entries, and keys should be mostly consistent from
184
+ * one purchase event to the next.
185
+ */
186
+ @ReactMethod
187
+ public void logPurchase(double purchaseAmount, String currencyCode,
188
+ @Nullable ReadableMap parameters) {
189
+ mAppEventLogger.logPurchase(
190
+ BigDecimal.valueOf(purchaseAmount),
191
+ Currency.getInstance(currencyCode),
192
+ Arguments.toBundle(parameters));
193
+ }
194
+
195
+ /**
196
+ * Logs an app event that tracks that the application was open via Push Notification.
197
+ * @param payload Notification payload received.
198
+ */
199
+ @ReactMethod
200
+ public void logPushNotificationOpen(@Nullable ReadableMap payload) {
201
+ mAppEventLogger.logPushNotificationOpen(Arguments.toBundle(payload));
202
+ }
203
+
204
+ /**
205
+ * Uploads product catalog product item as an app event.
206
+ *
207
+ * @param itemID – Unique ID for the item. Can be a variant for a product. Max size is 100.
208
+ * @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
209
+ * @param condition – Product condition: new, refurbished or used.
210
+ * @param description – Short text describing product. Max size is 5000.
211
+ * @param imageLink – Link to item image used in ad.
212
+ * @param link – Link to merchant's site where someone can buy the item.
213
+ * @param title – Title of item.
214
+ * @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).
215
+ * @param currencyCode – Currency used to specify the amount.
216
+ * @param gtin – Global Trade Item Number including UPC, EAN, JAN and ISBN
217
+ * @param mpn – Unique manufacture ID for product
218
+ * @param brand – Name of the brand Note: Either gtin, mpn or brand is required.
219
+ * @param parameters – Optional fields for deep link specification.
220
+ */
221
+ @ReactMethod
222
+ public void logProductItem(String itemID,
223
+ String availability,
224
+ String condition,
225
+ String description,
226
+ String imageLink,
227
+ String link,
228
+ String title,
229
+ double priceAmount,
230
+ String currencyCode,
231
+ String gtin,
232
+ String mpn,
233
+ String brand,
234
+ @Nullable ReadableMap parameters) {
235
+ mAppEventLogger.logProductItem(itemID,
236
+ AppEventsLogger.ProductAvailability.valueOf(availability.toUpperCase(Locale.ROOT)),
237
+ AppEventsLogger.ProductCondition.valueOf(condition.toUpperCase(Locale.ROOT)),
238
+ description,
239
+ imageLink,
240
+ link,
241
+ title,
242
+ BigDecimal.valueOf(priceAmount),
243
+ Currency.getInstance(currencyCode),
244
+ gtin,
245
+ mpn,
246
+ brand,
247
+ Arguments.toBundle(parameters));
248
+ }
249
+
250
+ /**
251
+ * Sets a user id to associate with all app events. This can be used to associate your own
252
+ * user id with the app events logged from this instance of an application.
253
+ *
254
+ * The user ID will be persisted between application instantces.
255
+ *
256
+ * @param userID A User ID
257
+ */
258
+ @ReactMethod
259
+ public void setUserID(final String userID) {
260
+ mAppEventLogger.setUserID(userID);
261
+ }
262
+
263
+ /**
264
+ * Clears the currently set user id.
265
+ */
266
+ @ReactMethod
267
+ public void clearUserID() {
268
+ mAppEventLogger.clearUserID();
269
+ }
270
+
271
+ /**
272
+ * Returns the set user id or null if not set
273
+ *
274
+ * @return The set User ID or null
275
+ */
276
+ @ReactMethod(isBlockingSynchronousMethod = true)
277
+ @Nullable
278
+ public String getUserID() {
279
+ return mAppEventLogger.getUserID();
280
+ }
281
+
282
+ /**
283
+ * Each app/device pair gets an GUID that is sent back with App Events and persisted with this
284
+ * app/device pair.
285
+ *
286
+ * @return The GUID for this app/device pair.
287
+ */
288
+ @ReactMethod
289
+ public void getAnonymousID(Promise promise) {
290
+ try {
291
+ promise.resolve(mAppEventLogger.getAnonymousAppDeviceGUID(mReactContext));
292
+ } catch (Exception e) {
293
+ promise.reject("E_ANONYMOUS_ID_ERROR", "Can not get anonymousID", e);
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Returns the advertiser id or null if not set
299
+ */
300
+ @ReactMethod
301
+ public void getAdvertiserID(Promise promise) {
302
+ try {
303
+ promise.resolve(mAttributionIdentifiers.getAndroidAdvertiserId());
304
+ } catch (Exception e) {
305
+ promise.reject("E_ADVERTISER_ID_ERROR", "Can not get advertiserID", e);
306
+ }
307
+ }
308
+
309
+ /**
310
+ * Returns the attribution id or null if not set
311
+ */
312
+ @ReactMethod
313
+ public void getAttributionID(Promise promise) {
314
+ try {
315
+ promise.resolve(mAttributionIdentifiers.getAttributionId());
316
+ } catch (Exception e) {
317
+ promise.reject("E_ATTRIBUTION_ID_ERROR", "Can not get attributionID", e);
318
+ }
319
+ }
320
+
321
+ private @Nullable String getNullableString(ReadableMap data, String key) {
322
+ return data.hasKey(key) ? data.getString(key) : null;
323
+ }
324
+
325
+ /**
326
+ * Set additional data about the user to increase chances of matching a Facebook user.
327
+ *
328
+ * @param userData Key-value pairs representing user data and their values.
329
+ */
330
+ @ReactMethod
331
+ public void setUserData(ReadableMap userData) {
332
+ AppEventsLogger.setUserData(
333
+ getNullableString(userData, "email"),
334
+ getNullableString(userData, "firstName"),
335
+ getNullableString(userData, "lastName"),
336
+ getNullableString(userData, "phone"),
337
+ getNullableString(userData, "dateOfBirth"),
338
+ getNullableString(userData, "gender"),
339
+ getNullableString(userData, "city"),
340
+ getNullableString(userData, "state"),
341
+ getNullableString(userData, "zip"),
342
+ getNullableString(userData, "country")
343
+ );
344
+ }
345
+
346
+ /**
347
+ * Explicitly flush any stored events to the server. Implicit flushes may happen depending on
348
+ * the value of getFlushBehavior. This method allows for explicit, app invoked flushing.
349
+ */
350
+ @ReactMethod
351
+ public void flush() {
352
+ mAppEventLogger.flush();
353
+ }
354
+
355
+ /**
356
+ * Sets and sends registration id to register the current app for push notifications.
357
+ * @param registrationId RegistrationId received from GCM.
358
+ */
359
+ @ReactMethod
360
+ public void setPushNotificationsRegistrationId(String registrationId) {
361
+ AppEventsLogger.setPushNotificationsRegistrationId(registrationId);
362
+ }
363
+
364
+ @Override
365
+ public Map<String, Object> getConstants() {
366
+ final Map<String, Object> constants = new HashMap<>();
367
+ final Map<String, Object> appEvents = new HashMap<>();
368
+ appEvents.put("AchievedLevel", AppEventsConstants.EVENT_NAME_ACHIEVED_LEVEL);
369
+ appEvents.put("AdClick", AppEventsConstants.EVENT_NAME_AD_CLICK);
370
+ appEvents.put("AdImpression", AppEventsConstants.EVENT_NAME_AD_IMPRESSION);
371
+ appEvents.put("AddedPaymentInfo", AppEventsConstants.EVENT_NAME_ADDED_PAYMENT_INFO);
372
+ appEvents.put("AddedToCart", AppEventsConstants.EVENT_NAME_ADDED_TO_CART);
373
+ appEvents.put("AddedToWishlist", AppEventsConstants.EVENT_NAME_ADDED_TO_WISHLIST);
374
+ appEvents.put("CompletedRegistration", AppEventsConstants.EVENT_NAME_COMPLETED_REGISTRATION);
375
+ appEvents.put("CompletedTutorial", AppEventsConstants.EVENT_NAME_COMPLETED_TUTORIAL);
376
+ appEvents.put("Contact", AppEventsConstants.EVENT_NAME_CONTACT);
377
+ appEvents.put("CustomizeProduct", AppEventsConstants.EVENT_NAME_CUSTOMIZE_PRODUCT);
378
+ appEvents.put("Donate", AppEventsConstants.EVENT_NAME_DONATE);
379
+ appEvents.put("FindLocation", AppEventsConstants.EVENT_NAME_FIND_LOCATION);
380
+ appEvents.put("InitiatedCheckout", AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT);
381
+ appEvents.put("Purchased", AppEventsConstants.EVENT_NAME_PURCHASED);
382
+ appEvents.put("Rated", AppEventsConstants.EVENT_NAME_RATED);
383
+ appEvents.put("Searched", AppEventsConstants.EVENT_NAME_SEARCHED);
384
+ appEvents.put("SpentCredits", AppEventsConstants.EVENT_NAME_SPENT_CREDITS);
385
+ appEvents.put("Schedule", AppEventsConstants.EVENT_NAME_SCHEDULE);
386
+ appEvents.put("StartTrial", AppEventsConstants.EVENT_NAME_START_TRIAL);
387
+ appEvents.put("SubmitApplication", AppEventsConstants.EVENT_NAME_SUBMIT_APPLICATION);
388
+ appEvents.put("Subscribe", AppEventsConstants.EVENT_NAME_SUBSCRIBE);
389
+ appEvents.put("UnlockedAchievement", AppEventsConstants.EVENT_NAME_UNLOCKED_ACHIEVEMENT);
390
+ appEvents.put("ViewedContent", AppEventsConstants.EVENT_NAME_VIEWED_CONTENT);
391
+ constants.put("AppEvents", appEvents);
392
+
393
+ final Map<String, Object> appEventParams = new HashMap<>();
394
+ appEventParams.put("AddType", AppEventsConstants.EVENT_PARAM_AD_TYPE);
395
+ appEventParams.put("Content", AppEventsConstants.EVENT_PARAM_CONTENT);
396
+ appEventParams.put("ContentID", AppEventsConstants.EVENT_PARAM_CONTENT_ID);
397
+ appEventParams.put("ContentType", AppEventsConstants.EVENT_PARAM_CONTENT_TYPE);
398
+ appEventParams.put("Currency", AppEventsConstants.EVENT_PARAM_CURRENCY);
399
+ appEventParams.put("Description", AppEventsConstants.EVENT_PARAM_DESCRIPTION);
400
+ appEventParams.put("Level", AppEventsConstants.EVENT_PARAM_LEVEL);
401
+ appEventParams.put("NumItems", AppEventsConstants.EVENT_PARAM_NUM_ITEMS);
402
+ appEventParams.put("MaxRatingValue", AppEventsConstants.EVENT_PARAM_MAX_RATING_VALUE);
403
+ appEventParams.put("OrderId", AppEventsConstants.EVENT_PARAM_ORDER_ID);
404
+ appEventParams.put("PaymentInfoAvailable", AppEventsConstants.EVENT_PARAM_PAYMENT_INFO_AVAILABLE);
405
+ appEventParams.put("RegistrationMethod", AppEventsConstants.EVENT_PARAM_REGISTRATION_METHOD);
406
+ appEventParams.put("SearchString", AppEventsConstants.EVENT_PARAM_SEARCH_STRING);
407
+ appEventParams.put("Success", AppEventsConstants.EVENT_PARAM_SUCCESS);
408
+ appEventParams.put("ValueNo", AppEventsConstants.EVENT_PARAM_VALUE_NO);
409
+ appEventParams.put("ValueYes", AppEventsConstants.EVENT_PARAM_VALUE_YES);
410
+ constants.put("AppEventParams", appEventParams);
411
+
412
+ return constants;
413
+ }
414
+ }
@@ -0,0 +1,86 @@
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 com.facebook.applinks.AppLinkData;
24
+ import com.facebook.internal.Utility;
25
+ import com.facebook.react.bridge.Promise;
26
+ import com.facebook.react.bridge.ReactApplicationContext;
27
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
28
+ import com.facebook.react.bridge.ReactMethod;
29
+ import com.facebook.react.module.annotations.ReactModule;
30
+
31
+ import org.json.JSONObject;
32
+
33
+ /**
34
+ * FBAppLinkModule
35
+ */
36
+ @ReactModule(name = FBAppLinkModule.NAME)
37
+ public class FBAppLinkModule extends ReactContextBaseJavaModule {
38
+ public static final String NAME = "FBAppLink";
39
+
40
+ private final ReactApplicationContext mReactContext;
41
+
42
+ public FBAppLinkModule(ReactApplicationContext reactContext) {
43
+ super(reactContext);
44
+ mReactContext = reactContext;
45
+ }
46
+
47
+ @Override
48
+ public String getName() {
49
+ return NAME;
50
+ }
51
+
52
+ /**
53
+ * The completion handler of fetchDeferredAppLinkData.
54
+ *
55
+ * @param promise If AppLinkData is found, resolve app link url, otherwise resolve null.
56
+ */
57
+ private AppLinkData.CompletionHandler createCompletionHandler(final Promise promise) {
58
+ return new AppLinkData.CompletionHandler() {
59
+ @Override
60
+ public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
61
+ if (appLinkData == null) {
62
+ promise.resolve(null);
63
+ } else {
64
+ promise.resolve(appLinkData.getTargetUri().toString());
65
+ }
66
+ }
67
+ };
68
+ }
69
+
70
+ /**
71
+ * Asynchronously fetches app link information that might have been stored for use after
72
+ * installation of the app.
73
+ *
74
+ * @param promise Used to pass app link to JS on fetch completed using completion handler.
75
+ */
76
+ @ReactMethod
77
+ public void fetchDeferredAppLink(final Promise promise) {
78
+ try {
79
+ AppLinkData.fetchDeferredAppLinkData(mReactContext.getApplicationContext(),
80
+ createCompletionHandler(promise));
81
+ } catch (Exception e) {
82
+ promise.resolve(null);
83
+ Utility.logd(getName(), "Received error while fetching deferred app link", e);
84
+ }
85
+ }
86
+ }
@@ -0,0 +1,94 @@
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.react.bridge.Arguments;
24
+ import com.facebook.react.bridge.Promise;
25
+ import com.facebook.react.bridge.ReactApplicationContext;
26
+ import com.facebook.react.bridge.ReactMethod;
27
+ import com.facebook.react.bridge.ReadableMap;
28
+ import com.facebook.react.bridge.WritableMap;
29
+ import com.facebook.react.module.annotations.ReactModule;
30
+ import com.facebook.share.model.GameRequestContent;
31
+ import com.facebook.gamingservices.GameRequestDialog;
32
+
33
+ /**
34
+ * Provides functionality to send requests in games.
35
+ * See https://developers.facebook.com/docs/games/requests
36
+ */
37
+ @ReactModule(name = FBGameRequestDialogModule.NAME)
38
+ public class FBGameRequestDialogModule extends FBSDKCallbackManagerBaseJavaModule {
39
+
40
+ public static final String NAME = "FBGameRequestDialog";
41
+
42
+ private class GameRequestDialogCallback extends ReactNativeFacebookSDKCallback<GameRequestDialog.Result> {
43
+
44
+ public GameRequestDialogCallback(Promise promise) {
45
+ super(promise);
46
+ }
47
+
48
+ @Override
49
+ public void onSuccess(GameRequestDialog.Result result) {
50
+ if (mPromise != null) {
51
+ WritableMap gameRequestDialogResult = Arguments.createMap();
52
+ gameRequestDialogResult.putString("requestId", result.getRequestId());
53
+ gameRequestDialogResult.putArray("to", Utility.listToReactArray(result.getRequestRecipients()));
54
+ mPromise.resolve(gameRequestDialogResult);
55
+ mPromise = null;
56
+ }
57
+ }
58
+ }
59
+
60
+ public FBGameRequestDialogModule(ReactApplicationContext reactContext, FBActivityEventListener activityEventListener) {
61
+ super(reactContext, activityEventListener);
62
+ }
63
+
64
+ @Override
65
+ public String getName() {
66
+ return NAME;
67
+ }
68
+
69
+ /**
70
+ * Indicates whether the game request dialog can be shown.
71
+ * @param promise Use promise to pass the result to JS whether the dialog can be shown.
72
+ */
73
+ @ReactMethod
74
+ public void canShow(Promise promise) {
75
+ promise.resolve(GameRequestDialog.canShow());
76
+ }
77
+
78
+ /**
79
+ * Shows a GameRequestDialog to send a request.
80
+ * @param gameRequestContentMap must be a valid {@link GameRequestContent}.
81
+ * @param promise Use promise to pass the game request dialog result to JS.
82
+ */
83
+ @ReactMethod
84
+ public void show(ReadableMap gameRequestContentMap, Promise promise) {
85
+ if (getCurrentActivity() != null) {
86
+ GameRequestDialog gameRequestDialog = new GameRequestDialog(getCurrentActivity());
87
+ GameRequestContent gameRequestContent = Utility.buildGameRequestContent(gameRequestContentMap);
88
+ gameRequestDialog.registerCallback(getCallbackManager(), new GameRequestDialogCallback(promise));
89
+ gameRequestDialog.show(gameRequestContent);
90
+ } else {
91
+ promise.reject("No current activity.");
92
+ }
93
+ }
94
+ }