react-native-genius-sdk 1.0.11 → 1.2.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 (65) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +130 -107
  3. package/android/build.gradle +3 -5
  4. package/android/gradle.properties +3 -3
  5. package/android/src/main/java/com/geniussdk/GeniusSdkModule.kt +66 -125
  6. package/android/src/main/java/com/geniussdk/JsValues.kt +19 -0
  7. package/ios/GeniusSdk.mm +17 -12
  8. package/ios/GeniusSdk.swift +65 -69
  9. package/lib/commonjs/bridgeValue.js +20 -0
  10. package/lib/commonjs/bridgeValue.js.map +1 -0
  11. package/lib/commonjs/dynamicLink.js +28 -0
  12. package/lib/commonjs/dynamicLink.js.map +1 -0
  13. package/lib/commonjs/events.js +33 -0
  14. package/lib/commonjs/events.js.map +1 -0
  15. package/lib/commonjs/index.js +84 -136
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/native.js +17 -0
  18. package/lib/commonjs/native.js.map +1 -0
  19. package/lib/commonjs/queryString.js +29 -0
  20. package/lib/commonjs/queryString.js.map +1 -0
  21. package/lib/module/bridgeValue.js +15 -0
  22. package/lib/module/bridgeValue.js.map +1 -0
  23. package/lib/module/dynamicLink.js +24 -0
  24. package/lib/module/dynamicLink.js.map +1 -0
  25. package/lib/module/events.js +28 -0
  26. package/lib/module/events.js.map +1 -0
  27. package/lib/module/index.js +66 -135
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/module/native.js +13 -0
  30. package/lib/module/native.js.map +1 -0
  31. package/lib/module/queryString.js +24 -0
  32. package/lib/module/queryString.js.map +1 -0
  33. package/lib/typescript/commonjs/src/bridgeValue.d.ts +3 -0
  34. package/lib/typescript/commonjs/src/bridgeValue.d.ts.map +1 -0
  35. package/lib/typescript/commonjs/src/dynamicLink.d.ts +2 -0
  36. package/lib/typescript/commonjs/src/dynamicLink.d.ts.map +1 -0
  37. package/lib/typescript/commonjs/src/events.d.ts +21 -0
  38. package/lib/typescript/commonjs/src/events.d.ts.map +1 -0
  39. package/lib/typescript/commonjs/src/index.d.ts +29 -50
  40. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/src/native.d.ts +20 -0
  42. package/lib/typescript/commonjs/src/native.d.ts.map +1 -0
  43. package/lib/typescript/commonjs/src/queryString.d.ts +3 -0
  44. package/lib/typescript/commonjs/src/queryString.d.ts.map +1 -0
  45. package/lib/typescript/module/src/bridgeValue.d.ts +3 -0
  46. package/lib/typescript/module/src/bridgeValue.d.ts.map +1 -0
  47. package/lib/typescript/module/src/dynamicLink.d.ts +2 -0
  48. package/lib/typescript/module/src/dynamicLink.d.ts.map +1 -0
  49. package/lib/typescript/module/src/events.d.ts +21 -0
  50. package/lib/typescript/module/src/events.d.ts.map +1 -0
  51. package/lib/typescript/module/src/index.d.ts +29 -50
  52. package/lib/typescript/module/src/index.d.ts.map +1 -1
  53. package/lib/typescript/module/src/native.d.ts +20 -0
  54. package/lib/typescript/module/src/native.d.ts.map +1 -0
  55. package/lib/typescript/module/src/queryString.d.ts +3 -0
  56. package/lib/typescript/module/src/queryString.d.ts.map +1 -0
  57. package/package.json +6 -8
  58. package/react-native-genius-sdk.podspec +3 -7
  59. package/src/bridgeValue.ts +16 -0
  60. package/src/dynamicLink.ts +43 -0
  61. package/src/events.ts +32 -0
  62. package/src/index.tsx +85 -174
  63. package/src/native.ts +32 -0
  64. package/src/queryString.ts +35 -0
  65. package/ios/GeniusSdk-Bridging-Header.h +0 -2
package/src/native.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ export interface GeniusSdkNativeModule {
4
+ connect(): Promise<string | null | undefined>;
5
+ isFirstOpen(): Promise<boolean>;
6
+ isStopped(): Promise<boolean>;
7
+ logEvent(eventName: string, eventValue: unknown): Promise<void>;
8
+ getDeferredDeepLinkData(): Promise<Record<string, string>>;
9
+ stop(isStopped: boolean): void;
10
+ setDebugLogging(enabled: boolean): void;
11
+ setMinTimeBetweenSessions(seconds: number): void;
12
+ setCollectAndroidId?(enabled: boolean): void;
13
+ setRequestsTrackingAuthorization?(enabled: boolean): void;
14
+ setReadsPasteboard?(enabled: boolean): void;
15
+ setCustomerUserId(id: string | null): void;
16
+ setPushToken(token: string | null): void;
17
+ triggerEvent(eventName: string, data: Record<string, unknown>): void;
18
+ addListener(eventName: string): void;
19
+ removeListeners(count: number): void;
20
+ }
21
+
22
+ const LINKING_ERROR =
23
+ `The package 'react-native-genius-sdk' doesn't seem to be linked. Make sure: \n\n` +
24
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
25
+ '- You rebuilt the app after installing the package\n' +
26
+ '- You are not using Expo Go\n';
27
+
28
+ export function nativeModule(): GeniusSdkNativeModule {
29
+ const module: GeniusSdkNativeModule | undefined = NativeModules.GeniusSDK;
30
+ if (!module) throw new Error(LINKING_ERROR);
31
+ return module;
32
+ }
@@ -0,0 +1,35 @@
1
+ export function parse(query: string): Record<string, string> {
2
+ return Object.fromEntries(
3
+ query
4
+ .split('&')
5
+ .filter((segment) => segment !== '')
6
+ .map(parseSegment)
7
+ .filter(([key]) => key !== '')
8
+ );
9
+ }
10
+
11
+ export function parseUrl(url: string): Record<string, string> {
12
+ const start = url.indexOf('?');
13
+ if (start < 0) return {};
14
+ const query = url.slice(start + 1);
15
+ const end = query.indexOf('#');
16
+ return parse(end < 0 ? query : query.slice(0, end));
17
+ }
18
+
19
+ function parseSegment(segment: string): [key: string, value: string] {
20
+ const separator = segment.indexOf('=');
21
+ return separator < 0
22
+ ? [decode(segment), '']
23
+ : [
24
+ decode(segment.slice(0, separator)),
25
+ decode(segment.slice(separator + 1)),
26
+ ];
27
+ }
28
+
29
+ function decode(raw: string): string {
30
+ try {
31
+ return decodeURIComponent(raw.replace(/\+/g, ' '));
32
+ } catch {
33
+ return raw;
34
+ }
35
+ }
@@ -1,2 +0,0 @@
1
- #import <React/RCTBridgeModule.h>
2
- #import <React/RCTViewManager.h>