@screeb/react-native 0.4.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.
@@ -0,0 +1,20 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "screeb-module"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "10.0" }
14
+ s.source = { :git => "https://github.com/ScreebApp/sdk-reactnative.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
17
+
18
+ s.dependency "React-Core"
19
+ s.dependency "Screeb", '~> 1.4.0'
20
+ end
package/src/index.tsx ADDED
@@ -0,0 +1,42 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `The package '@screeb/react-native' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo managed workflow\n';
8
+
9
+ const ScreebModule = NativeModules.ScreebModule
10
+ ? NativeModules.ScreebModule
11
+ : new Proxy(
12
+ {},
13
+ {
14
+ get() {
15
+ throw new Error(LINKING_ERROR);
16
+ },
17
+ }
18
+ );
19
+
20
+ export function initSdk(
21
+ androidChannelId: string,
22
+ iosChannelId: string,
23
+ userId?: string,
24
+ properties?: Map<string, any>) {
25
+ if (Platform.OS === 'ios') {
26
+ return ScreebModule.initSdk(iosChannelId, userId, properties);
27
+ } else {
28
+ return ScreebModule.initSdk(androidChannelId, userId, properties);
29
+ }
30
+ }
31
+ export function setIdentity(userId: string, properties?: Map<string, any>) {
32
+ return ScreebModule.setIdentity(userId, properties);
33
+ }
34
+ export function trackEvent(name: string, properties?: Map<string, any>) {
35
+ return ScreebModule.trackEvent(name, properties);
36
+ }
37
+ export function trackScreen(name: string, properties?: Map<string, any>) {
38
+ return ScreebModule.trackScreen(name, properties);
39
+ }
40
+ export function setProperties(properties?: Map<string, any>) {
41
+ return ScreebModule.setProperties(properties);
42
+ }