@grouplinknetwork/rn-grouplink-sdk 2.3.12 → 2.5.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 (28) hide show
  1. package/android/build.gradle +8 -115
  2. package/android/src/main/AndroidManifest.xml +1 -2
  3. package/android/src/main/java/com/grouplinksdk/GrouplinkSdkModule.java +112 -92
  4. package/android/src/main/java/com/grouplinksdk/GrouplinkSdkPackage.java +30 -14
  5. package/grouplink-sdk.podspec +5 -3
  6. package/ios/GrouplinkSdk-Bridging-Header.h +2 -2
  7. package/ios/GrouplinkSdk.mm +180 -0
  8. package/ios/GrouplinkSdk.swift +18 -27
  9. package/ios/GrouplinkSdk.xcodeproj/project.pbxproj +27 -4
  10. package/lib/commonjs/NativeGrouplinkSdk.js +9 -0
  11. package/lib/commonjs/NativeGrouplinkSdk.js.map +1 -0
  12. package/lib/commonjs/index.js +69 -64
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/module/NativeGrouplinkSdk.js +3 -0
  15. package/lib/module/NativeGrouplinkSdk.js.map +1 -0
  16. package/lib/module/index.js +64 -65
  17. package/lib/module/index.js.map +1 -1
  18. package/lib/typescript/NativeGrouplinkSdk.d.ts +21 -0
  19. package/lib/typescript/NativeGrouplinkSdk.d.ts.map +1 -0
  20. package/lib/typescript/index.d.ts +13 -8
  21. package/lib/typescript/index.d.ts.map +1 -1
  22. package/package.json +10 -2
  23. package/src/NativeGrouplinkSdk.ts +25 -0
  24. package/src/index.tsx +88 -82
  25. package/ios/GrouplinkSdk.m +0 -19
  26. package/ios/GrouplinkSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  27. package/ios/GrouplinkSdk.xcodeproj/project.xcworkspace/xcuserdata/alessandrodearaujo.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  28. package/ios/GrouplinkSdk.xcodeproj/xcuserdata/alessandrodearaujo.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -1,52 +1,21 @@
1
- buildscript {
2
- repositories {
3
- google()
4
- mavenCentral()
5
- mavenLocal()
6
- maven { url 'https://jitpack.io' }
7
- }
8
-
9
- dependencies {
10
- classpath 'com.android.tools.build:gradle:3.5.3'
11
- }
12
- }
13
-
14
- def isNewArchitectureEnabled() {
15
- return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
16
- }
17
-
18
- apply plugin: 'com.android.library'
19
-
20
- if (isNewArchitectureEnabled()) {
21
- apply plugin: 'com.facebook.react'
22
- }
23
-
24
- def getExtOrDefault(name) {
25
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['GrouplinkSdk_' + name]
26
- }
27
-
28
- def getExtOrIntegerDefault(name) {
29
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['GrouplinkSdk_' + name]).toInteger()
30
- }
1
+ apply plugin: "com.android.library"
2
+ apply plugin: "com.facebook.react"
31
3
 
32
4
  android {
33
- compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
5
+ namespace "com.grouplinksdk"
6
+ compileSdkVersion 34
34
7
 
35
8
  defaultConfig {
36
- minSdkVersion getExtOrIntegerDefault('minSdkVersion')
37
- targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
9
+ minSdkVersion 24
10
+ targetSdkVersion 34
39
11
  }
12
+
40
13
  buildTypes {
41
14
  release {
42
15
  minifyEnabled false
43
16
  }
44
17
  }
45
18
 
46
- lintOptions {
47
- disable 'GradleCompatible'
48
- }
49
-
50
19
  compileOptions {
51
20
  sourceCompatibility JavaVersion.VERSION_1_8
52
21
  targetCompatibility JavaVersion.VERSION_1_8
@@ -56,85 +25,9 @@ android {
56
25
  repositories {
57
26
  mavenCentral()
58
27
  google()
59
-
60
- def found = false
61
- def defaultDir = null
62
- def androidSourcesName = 'React Native sources'
63
-
64
- if (rootProject.ext.has('reactNativeAndroidRoot')) {
65
- defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
66
- } else {
67
- defaultDir = new File(
68
- projectDir,
69
- '/../../../node_modules/react-native/android'
70
- )
71
- }
72
-
73
- if (defaultDir.exists()) {
74
- maven {
75
- url defaultDir.toString()
76
- name androidSourcesName
77
- }
78
-
79
- logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
80
- found = true
81
- } else {
82
- def parentDir = rootProject.projectDir
83
-
84
- 1.upto(5, {
85
- if (found) return true
86
- parentDir = parentDir.parentFile
87
-
88
- def androidSourcesDir = new File(
89
- parentDir,
90
- 'node_modules/react-native'
91
- )
92
-
93
- def androidPrebuiltBinaryDir = new File(
94
- parentDir,
95
- 'node_modules/react-native/android'
96
- )
97
-
98
- if (androidPrebuiltBinaryDir.exists()) {
99
- maven {
100
- url androidPrebuiltBinaryDir.toString()
101
- name androidSourcesName
102
- }
103
-
104
- logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
105
- found = true
106
- } else if (androidSourcesDir.exists()) {
107
- maven {
108
- url androidSourcesDir.toString()
109
- name androidSourcesName
110
- }
111
-
112
- logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
113
- found = true
114
- }
115
- })
116
- }
117
-
118
- if (!found) {npm
119
- throw new GradleException(
120
- "${project.name}: unable to locate React Native android sources. " +
121
- "Ensure you have you installed React Native as a dependency in your project and try again."
122
- )
123
- }
124
28
  }
125
29
 
126
-
127
30
  dependencies {
128
- //noinspection GradleDynamicVersion
129
- implementation "com.facebook.react:react-native:+"
31
+ implementation "com.facebook.react:react-android"
130
32
  implementation "com.grouplinknetwork:lib-grouplinknetwork:4.+"
131
33
  }
132
-
133
- if (isNewArchitectureEnabled()) {
134
- react {
135
- jsRootDir = file("../src/")
136
- libraryName = "GrouplinkSdk"
137
- codegenJavaPackageName = "com.grouplinksdk"
138
- }
139
- }
140
-
@@ -1,5 +1,4 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.grouplinksdk">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
2
  <uses-permission
4
3
  android:name="android.permission.INTERNET" />
5
4
  <uses-permission
@@ -2,8 +2,6 @@ package com.grouplinksdk;
2
2
 
3
3
  import androidx.annotation.NonNull;
4
4
  import android.content.Context;
5
- import android.content.pm.ApplicationInfo;
6
- import android.os.Bundle;
7
5
  import android.util.Log;
8
6
  import android.net.Uri;
9
7
  import android.app.NotificationManager;
@@ -12,28 +10,23 @@ import android.content.Intent;
12
10
  import android.provider.Settings;
13
11
  import android.os.Build;
14
12
 
15
- import com.facebook.react.bridge.Callback;
16
13
  import com.facebook.react.bridge.LifecycleEventListener;
17
14
  import com.facebook.react.bridge.Promise;
18
15
  import com.facebook.react.bridge.ReactApplicationContext;
19
- import com.facebook.react.bridge.ReactContext;
20
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
21
16
  import com.facebook.react.bridge.ReactMethod;
22
- import com.facebook.react.bridge.ReadableArray;
23
- import com.facebook.react.bridge.ReadableMap;
24
- import com.facebook.react.modules.core.DeviceEventManagerModule;
25
17
  import com.facebook.react.module.annotations.ReactModule;
26
18
  import android.os.Handler;
27
19
  import android.os.Looper;
28
- import com.grouplinknetwork.GrouplinkUserIdListener;
29
20
 
30
21
  import com.grouplinknetwork.GroupLink;
31
22
 
23
+ // NativeGrouplinkSdkSpec is generated by Codegen from src/NativeGroupLinkSDK.ts.
24
+ // The exact class name is derived from build.gradle libraryName="GrouplinkSdk"
25
+ // → NativeGrouplinkSdkSpec in package com.grouplinksdk.
32
26
  @ReactModule(name = GrouplinkSdkModule.NAME)
33
- public class GrouplinkSdkModule extends ReactContextBaseJavaModule implements LifecycleEventListener{
27
+ public class GrouplinkSdkModule extends NativeGrouplinkSdkSpec implements LifecycleEventListener {
34
28
  public static final String NAME = "RNGroupLinkSDK";
35
- private ReactApplicationContext mReactApplicationContext;
36
- private ReactContext mReactContext;
29
+ private final ReactApplicationContext mReactApplicationContext;
37
30
  private boolean glInitDone = false;
38
31
  private String token = "";
39
32
  private boolean debbugable = false;
@@ -41,8 +34,7 @@ public class GrouplinkSdkModule extends ReactContextBaseJavaModule implements Li
41
34
  public GrouplinkSdkModule(ReactApplicationContext reactContext) {
42
35
  super(reactContext);
43
36
  mReactApplicationContext = reactContext;
44
- mReactContext = reactContext;
45
- mReactContext.addLifecycleEventListener(this);
37
+ reactContext.addLifecycleEventListener(this);
46
38
  }
47
39
 
48
40
  @Override
@@ -51,36 +43,24 @@ public class GrouplinkSdkModule extends ReactContextBaseJavaModule implements Li
51
43
  return NAME;
52
44
  }
53
45
 
46
+ // -------------------------------------------------------------------------
47
+ // Android-specific methods
48
+ // -------------------------------------------------------------------------
49
+
50
+ @Override
54
51
  @ReactMethod
55
- public void getUserIdAndroid(Promise promise){
52
+ public void getUserIdAndroid(Promise promise) {
56
53
  Context context = mReactApplicationContext.getApplicationContext();
57
- String userId = "undefined usrId";
58
- try{
59
- userId = GroupLink.getUserId(context);
54
+ try {
55
+ String userId = GroupLink.getUserId(context);
60
56
  promise.resolve(userId);
61
- }catch(Exception e){
57
+ } catch (Exception e) {
62
58
  e.printStackTrace();
63
- promise.reject("not registered");
59
+ promise.reject("not_registered", e.getMessage());
64
60
  }
65
61
  }
66
62
 
67
- // Example method
68
- // See https://reactnative.dev/docs/native-modules-android
69
- @ReactMethod
70
- public void multiply(double a, double b, Promise promise) {
71
- promise.resolve(a * b);
72
- }
73
-
74
-
75
- public void registerAndroid(Context context, String token, boolean debuggable) {
76
- Handler handler = new Handler(Looper.getMainLooper());
77
- handler.post(new Runnable() {
78
- public void run(){
79
- GroupLink.register(context, token, debuggable);
80
- }
81
- });
82
- }
83
-
63
+ @Override
84
64
  @ReactMethod
85
65
  public void startAndroid(String token, boolean debbugable) {
86
66
  this.token = token;
@@ -88,47 +68,26 @@ public class GrouplinkSdkModule extends ReactContextBaseJavaModule implements Li
88
68
  initGrouplink();
89
69
  }
90
70
 
71
+ @Override
91
72
  @ReactMethod
92
- public void setFirebaseToken(String token){
73
+ public void setFirebaseToken(String token) {
93
74
  Context context = mReactApplicationContext.getApplicationContext();
94
- if(token.equalsIgnoreCase("")){
95
- Log.e("GL_K01", "not initing");
75
+ if (token.equalsIgnoreCase("")) {
76
+ Log.e("GL_K01", "not initing");
96
77
  return;
97
78
  }
98
- if (context == null) {
99
- // in some cases, especially when react-native-navigation is installed,
100
- // the activity can be null, so we can initialize with the context instead
101
- context = mReactApplicationContext.getApplicationContext();
102
- }
103
- try{
104
- GroupLink.setFirebaseToken(context, token);
105
- }catch(Exception e){
79
+ try {
80
+ GroupLink.setFirebaseToken(context, token);
81
+ } catch (Exception e) {
106
82
  e.printStackTrace();
107
83
  }
108
84
  }
109
85
 
110
- private void initGrouplink() {
111
- Context context = mReactApplicationContext.getApplicationContext();
112
- if(token.equalsIgnoreCase("")){
113
- Log.e("GL_K01", "not initing");
114
- return;
115
- }
116
- if (context == null) {
117
- // in some cases, especially when react-native-navigation is installed,
118
- // the activity can be null, so we can initialize with the context instead
119
- context = mReactApplicationContext.getApplicationContext();
120
- }
121
- Log.d("AndroidGL", "init android with: " + token);
122
- registerAndroid(context, token, debbugable); //initGrouplink()
123
- }
124
-
86
+ @Override
125
87
  @ReactMethod
126
88
  public void requestFullIntentPermissionAndroid() {
127
89
  try {
128
90
  Context context = mReactApplicationContext.getApplicationContext();
129
- if (context == null) {
130
- context = mReactApplicationContext.getApplicationContext();
131
- }
132
91
  NotificationManager notificationManager = (NotificationManager) context.getSystemService(ReactApplicationContext.NOTIFICATION_SERVICE);
133
92
  if (Build.VERSION.SDK_INT >= 34) {
134
93
  if (!notificationManager.canUseFullScreenIntent()) {
@@ -142,40 +101,35 @@ public class GrouplinkSdkModule extends ReactContextBaseJavaModule implements Li
142
101
  Log.e("FullIntent", "Failed to open settings: " + e.getMessage());
143
102
  }
144
103
  }
104
+
105
+ @Override
145
106
  @ReactMethod
146
- public void setNotificationName(String notificationName) {
147
- try{
107
+ public void setNotificationNameAndroid(String notificationName) {
108
+ try {
148
109
  Context context = mReactApplicationContext.getApplicationContext();
149
- if (context == null) {
150
- context = mReactApplicationContext.getApplicationContext();
151
- }
152
- GroupLink.setNotificationName(context, notificationName);
153
- }catch (Exception e) {
154
- Log.e("setNotificationName", "Failed to open settings: " + e.getMessage());
110
+ GroupLink.setNotificationName(context, notificationName);
111
+ } catch (Exception e) {
112
+ Log.e("setNotificationName", "Failed: " + e.getMessage());
155
113
  }
156
-
157
114
  }
158
115
 
116
+ @Override
159
117
  @ReactMethod
160
- public String getNotificationName() {
161
- try{
118
+ public void getNotificationNameAndroid(Promise promise) {
119
+ try {
162
120
  Context context = mReactApplicationContext.getApplicationContext();
163
- if (context == null) {
164
- context = mReactApplicationContext.getApplicationContext();
165
- }
166
- return GroupLink.getNotificationName(context);
167
- }catch (Exception e) {
168
- Log.e("getNotificationName", "Failed to open settings: " + e.getMessage());
121
+ promise.resolve(GroupLink.getNotificationName(context));
122
+ } catch (Exception e) {
123
+ Log.e("getNotificationName", "Failed: " + e.getMessage());
124
+ promise.reject("error", e.getMessage());
169
125
  }
170
- return "Nothing";
171
126
  }
127
+
128
+ @Override
172
129
  @ReactMethod
173
- public void requestScheduleExactAlarm(){
130
+ public void requestScheduleExactAlarm() {
174
131
  try {
175
132
  Context context = mReactApplicationContext.getApplicationContext();
176
- if (context == null) {
177
- context = mReactApplicationContext.getApplicationContext();
178
- }
179
133
  AlarmManager alarmManager = (AlarmManager) context.getSystemService(ReactApplicationContext.ALARM_SERVICE);
180
134
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !alarmManager.canScheduleExactAlarms()) {
181
135
  Intent intent = new Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
@@ -184,23 +138,89 @@ public class GrouplinkSdkModule extends ReactContextBaseJavaModule implements Li
184
138
  context.startActivity(intent);
185
139
  }
186
140
  } catch (Exception e) {
187
- Log.e("requestScheduleExactAlarm", "Failed to open settings: " + e.getMessage());
141
+ Log.e("requestScheduleExactAlarm", "Failed: " + e.getMessage());
188
142
  }
189
143
  }
190
-
144
+
145
+ // -------------------------------------------------------------------------
146
+ // iOS-only methods — no-ops on Android
147
+ // -------------------------------------------------------------------------
191
148
 
192
149
  @Override
193
- public void onHostDestroy() {
150
+ @ReactMethod
151
+ public void getUserID(Promise promise) {
152
+ promise.reject("unsupported", "getUserID is iOS only");
153
+ }
154
+
155
+ @Override
156
+ @ReactMethod
157
+ public void setDevicePushToken(String withPushToken) {
158
+ // iOS only
159
+ }
160
+
161
+ @Override
162
+ @ReactMethod
163
+ public void startIOS(String withToken) {
164
+ // iOS only
165
+ }
194
166
 
167
+ @Override
168
+ @ReactMethod
169
+ public void startBluetoothIOS() {
170
+ // iOS only
171
+ }
172
+
173
+ @Override
174
+ @ReactMethod
175
+ public void checkBluetoothIOS() {
176
+ // iOS only
177
+ }
178
+
179
+ @Override
180
+ @ReactMethod
181
+ public void startLocationIOS() {
182
+ // iOS only
195
183
  }
196
184
 
197
185
  @Override
198
- public void onHostPause() {
186
+ @ReactMethod
187
+ public void setNotificationNameIOS(String withNotificationName) {
188
+ // iOS only
189
+ }
199
190
 
191
+ @Override
192
+ @ReactMethod
193
+ public void getNotificationNameIOS(Promise promise) {
194
+ promise.reject("unsupported", "getNotificationNameIOS is iOS only");
200
195
  }
201
196
 
197
+ // -------------------------------------------------------------------------
198
+ // Lifecycle
199
+ // -------------------------------------------------------------------------
200
+
201
+ @Override
202
+ public void onHostDestroy() {}
203
+
204
+ @Override
205
+ public void onHostPause() {}
206
+
202
207
  @Override
203
208
  public void onHostResume() {
209
+ initGrouplink();
204
210
  }
205
211
 
212
+ // -------------------------------------------------------------------------
213
+ // Private helpers
214
+ // -------------------------------------------------------------------------
215
+
216
+ private void initGrouplink() {
217
+ Context context = mReactApplicationContext.getApplicationContext();
218
+ if (token.equalsIgnoreCase("")) {
219
+ Log.e("GL_K01", "not initing — token is empty");
220
+ return;
221
+ }
222
+ Log.d("AndroidGL", "init android with: " + token);
223
+ Handler handler = new Handler(Looper.getMainLooper());
224
+ handler.post(() -> GroupLink.register(context, token, debbugable));
225
+ }
206
226
  }
@@ -1,28 +1,44 @@
1
1
  package com.grouplinksdk;
2
2
 
3
3
  import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
4
5
 
5
- import com.facebook.react.ReactPackage;
6
+ import com.facebook.react.TurboReactPackage;
6
7
  import com.facebook.react.bridge.NativeModule;
7
8
  import com.facebook.react.bridge.ReactApplicationContext;
8
- import com.facebook.react.uimanager.ViewManager;
9
+ import com.facebook.react.module.model.ReactModuleInfo;
10
+ import com.facebook.react.module.model.ReactModuleInfoProvider;
9
11
 
10
- import java.util.ArrayList;
11
- import java.util.Collections;
12
- import java.util.List;
12
+ import java.util.HashMap;
13
+ import java.util.Map;
13
14
 
14
- public class GrouplinkSdkPackage implements ReactPackage {
15
- @NonNull
15
+ public class GrouplinkSdkPackage extends TurboReactPackage {
16
+
17
+ @Nullable
16
18
  @Override
17
- public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
18
- List<NativeModule> modules = new ArrayList<>();
19
- modules.add(new GrouplinkSdkModule(reactContext));
20
- return modules;
19
+ public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) {
20
+ if (name.equals(GrouplinkSdkModule.NAME)) {
21
+ return new GrouplinkSdkModule(reactContext);
22
+ }
23
+ return null;
21
24
  }
22
25
 
23
- @NonNull
24
26
  @Override
25
- public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
26
- return Collections.emptyList();
27
+ public ReactModuleInfoProvider getReactModuleInfoProvider() {
28
+ return () -> {
29
+ final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
30
+ moduleInfos.put(
31
+ GrouplinkSdkModule.NAME,
32
+ new ReactModuleInfo(
33
+ GrouplinkSdkModule.NAME,
34
+ GrouplinkSdkModule.NAME,
35
+ false, // canOverrideExistingModule
36
+ false, // needsEagerInit
37
+ false, // hasConstants
38
+ true // isTurboModule
39
+ )
40
+ );
41
+ return moduleInfos;
42
+ };
27
43
  }
28
44
  }
@@ -11,13 +11,13 @@ Pod::Spec.new do |s|
11
11
  s.license = package["license"]
12
12
  s.authors = package["author"]
13
13
 
14
- s.platforms = { :ios => "10.0" }
14
+ s.platforms = { :ios => "13.0" }
15
15
  s.source = { :git => "https://github.com/amazingvitor/grouplink-sdk.git", :tag => "#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
+ s.dependency "GroupLinkSDK", "~> 5"
19
20
  s.dependency "React-Core"
20
- s.dependency "GroupLinkSDK"
21
21
 
22
22
  # Don't install the dependencies when we run `pod install` in the old architecture.
23
23
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
@@ -28,9 +28,11 @@ Pod::Spec.new do |s|
28
28
  }
29
29
 
30
30
  s.dependency "React-Codegen"
31
- s.dependency "RCT-Folly"
31
+ # s.dependency "RCT-Folly"
32
32
  s.dependency "RCTRequired"
33
33
  s.dependency "RCTTypeSafety"
34
34
  s.dependency "ReactCommon/turbomodule/core"
35
35
  end
36
+
37
+ install_modules_dependencies(s)
36
38
  end
@@ -1,2 +1,2 @@
1
- #import <React/RCTBridgeModule.h>
2
- #import <React/RCTViewManager.h>
1
+ // Bridging header retained for CocoaPods compatibility.
2
+ // The React Native module is implemented in GrouplinkSdk.mm (Obj-C++).