@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.
- package/android/build.gradle +8 -115
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/grouplinksdk/GrouplinkSdkModule.java +112 -92
- package/android/src/main/java/com/grouplinksdk/GrouplinkSdkPackage.java +30 -14
- package/grouplink-sdk.podspec +5 -3
- package/ios/GrouplinkSdk-Bridging-Header.h +2 -2
- package/ios/GrouplinkSdk.mm +180 -0
- package/ios/GrouplinkSdk.swift +18 -27
- package/ios/GrouplinkSdk.xcodeproj/project.pbxproj +27 -4
- package/lib/commonjs/NativeGrouplinkSdk.js +9 -0
- package/lib/commonjs/NativeGrouplinkSdk.js.map +1 -0
- package/lib/commonjs/index.js +69 -64
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeGrouplinkSdk.js +3 -0
- package/lib/module/NativeGrouplinkSdk.js.map +1 -0
- package/lib/module/index.js +64 -65
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/NativeGrouplinkSdk.d.ts +21 -0
- package/lib/typescript/NativeGrouplinkSdk.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +13 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +10 -2
- package/src/NativeGrouplinkSdk.ts +25 -0
- package/src/index.tsx +88 -82
- package/ios/GrouplinkSdk.m +0 -19
- package/ios/GrouplinkSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/GrouplinkSdk.xcodeproj/project.xcworkspace/xcuserdata/alessandrodearaujo.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/GrouplinkSdk.xcodeproj/xcuserdata/alessandrodearaujo.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/lib/module/index.js
CHANGED
|
@@ -1,131 +1,130 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ios: "- You have run 'pod install'\n",
|
|
4
|
-
default: ''
|
|
5
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
6
|
-
const RNGroupLinkSDK = NativeModules.RNGroupLinkSDK ? NativeModules.RNGroupLinkSDK : new Proxy({}, {
|
|
7
|
-
get() {
|
|
8
|
-
throw new Error(LINKING_ERROR);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
1
|
+
import { PermissionsAndroid, Platform } from 'react-native';
|
|
2
|
+
import NativeGroupLinkSDK from './NativeGrouplinkSdk';
|
|
11
3
|
export async function getUserId() {
|
|
12
4
|
if (isAndroid()) {
|
|
13
|
-
const userID = await
|
|
14
|
-
if (userID
|
|
5
|
+
const userID = await NativeGroupLinkSDK.getUserIdAndroid();
|
|
6
|
+
if (userID !== 'User not registered yet.') {
|
|
15
7
|
return Promise.resolve(userID);
|
|
16
8
|
} else {
|
|
17
|
-
return Promise.reject(
|
|
9
|
+
return Promise.reject('UserID not registered yet');
|
|
18
10
|
}
|
|
19
11
|
}
|
|
20
12
|
if (isiOS()) {
|
|
21
|
-
|
|
22
|
-
if (userID != null) {
|
|
23
|
-
return Promise.resolve(userID);
|
|
24
|
-
} else {
|
|
25
|
-
return Promise.reject("UserID not registered yet");
|
|
26
|
-
}
|
|
13
|
+
return NativeGroupLinkSDK.getUserID();
|
|
27
14
|
}
|
|
28
|
-
return Promise.reject(
|
|
15
|
+
return Promise.reject('Internal Error');
|
|
29
16
|
}
|
|
30
17
|
export function setFirebaseToken(token) {
|
|
31
18
|
if (isAndroid()) {
|
|
32
|
-
|
|
33
|
-
RNGroupLinkSDK.setFirebaseToken(token);
|
|
19
|
+
NativeGroupLinkSDK.setFirebaseToken(token);
|
|
34
20
|
}
|
|
35
21
|
}
|
|
36
22
|
export function startBluetoothIOS() {
|
|
37
23
|
if (isiOS()) {
|
|
38
|
-
|
|
39
|
-
return RNGroupLinkSDK.startBluetoothIOS();
|
|
24
|
+
NativeGroupLinkSDK.startBluetoothIOS();
|
|
40
25
|
}
|
|
41
|
-
return;
|
|
42
26
|
}
|
|
43
27
|
export function setDevicePushTokenIOS(token) {
|
|
44
|
-
|
|
28
|
+
if (isiOS()) {
|
|
29
|
+
NativeGroupLinkSDK.setDevicePushToken(token);
|
|
30
|
+
}
|
|
45
31
|
}
|
|
46
32
|
export function startLocationIOS() {
|
|
47
33
|
if (isiOS()) {
|
|
48
|
-
|
|
49
|
-
return RNGroupLinkSDK.startLocationIOS();
|
|
34
|
+
NativeGroupLinkSDK.startLocationIOS();
|
|
50
35
|
}
|
|
51
|
-
return;
|
|
52
36
|
}
|
|
53
37
|
function isAndroid() {
|
|
54
|
-
return Platform.OS
|
|
38
|
+
return Platform.OS === 'android';
|
|
55
39
|
}
|
|
56
40
|
function isiOS() {
|
|
57
|
-
return Platform.OS
|
|
58
|
-
}
|
|
59
|
-
function startAndroid(withToken, debbugable) {
|
|
60
|
-
console.log('Group Link SDK (Android) - Start with token: ', withToken);
|
|
61
|
-
return RNGroupLinkSDK.startAndroid(withToken, debbugable);
|
|
62
|
-
}
|
|
63
|
-
function startIOS(withToken) {
|
|
64
|
-
console.log('Group Link SDK (IOS) - Start with token: ', withToken);
|
|
65
|
-
return RNGroupLinkSDK.startIOS(withToken);
|
|
41
|
+
return Platform.OS === 'ios';
|
|
66
42
|
}
|
|
67
43
|
export function startGrouplink(withToken, debbugable) {
|
|
68
44
|
if (isiOS()) {
|
|
69
|
-
startIOS(withToken);
|
|
45
|
+
NativeGroupLinkSDK.startIOS(withToken);
|
|
70
46
|
}
|
|
71
47
|
if (isAndroid()) {
|
|
72
|
-
startAndroid(withToken, debbugable);
|
|
48
|
+
NativeGroupLinkSDK.startAndroid(withToken, debbugable);
|
|
73
49
|
}
|
|
74
50
|
}
|
|
75
51
|
export function startGrouplinkAndroid(withToken, debbugable) {
|
|
76
52
|
if (isAndroid()) {
|
|
77
|
-
startAndroid(withToken, debbugable);
|
|
53
|
+
NativeGroupLinkSDK.startAndroid(withToken, debbugable);
|
|
78
54
|
}
|
|
79
55
|
}
|
|
80
56
|
export function startGrouplinkIOS(withToken) {
|
|
81
57
|
if (isiOS()) {
|
|
82
|
-
startIOS(withToken);
|
|
58
|
+
NativeGroupLinkSDK.startIOS(withToken);
|
|
83
59
|
}
|
|
84
60
|
}
|
|
85
61
|
export function checkBluetoothIOS() {
|
|
86
|
-
if (isiOS())
|
|
62
|
+
if (isiOS()) {
|
|
63
|
+
NativeGroupLinkSDK.checkBluetoothIOS();
|
|
64
|
+
}
|
|
87
65
|
}
|
|
88
66
|
export async function startBluetoothAndroid() {
|
|
89
|
-
if (!(Platform.OS ===
|
|
67
|
+
if (!(Platform.OS === 'android' && Platform.Version >= 31)) return;
|
|
90
68
|
const bluetoothPermission = await PermissionsAndroid.requestMultiple([PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT]);
|
|
91
|
-
if (bluetoothPermission[
|
|
69
|
+
if (bluetoothPermission['android.permission.BLUETOOTH_SCAN'] === PermissionsAndroid.RESULTS.GRANTED && bluetoothPermission['android.permission.BLUETOOTH_ADVERTISE'] === PermissionsAndroid.RESULTS.GRANTED && bluetoothPermission['android.permission.BLUETOOTH_CONNECT'] === PermissionsAndroid.RESULTS.GRANTED) {
|
|
70
|
+
NativeGroupLinkSDK.startAndroid('', false);
|
|
71
|
+
}
|
|
92
72
|
}
|
|
93
|
-
;
|
|
94
73
|
export async function startLocationAndroid() {
|
|
95
|
-
if (!(Platform.OS
|
|
74
|
+
if (!(Platform.OS === 'android' && Platform.Version >= 23)) return;
|
|
96
75
|
const locationPermission = await PermissionsAndroid.requestMultiple([PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION]);
|
|
97
|
-
if (locationPermission[
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
76
|
+
if (locationPermission['android.permission.ACCESS_COARSE_LOCATION'] === PermissionsAndroid.RESULTS.GRANTED && locationPermission['android.permission.ACCESS_FINE_LOCATION'] === PermissionsAndroid.RESULTS.GRANTED) {
|
|
77
|
+
// Permissions granted
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function startLocation() {
|
|
81
|
+
if (isiOS()) {
|
|
82
|
+
NativeGroupLinkSDK.startLocationIOS();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function startBluetooth() {
|
|
86
|
+
if (isiOS()) {
|
|
87
|
+
NativeGroupLinkSDK.startBluetoothIOS();
|
|
101
88
|
}
|
|
102
89
|
}
|
|
103
90
|
export function requestFullIntentPermissionAndroid() {
|
|
104
91
|
if (isAndroid()) {
|
|
105
|
-
|
|
92
|
+
NativeGroupLinkSDK.requestFullIntentPermissionAndroid();
|
|
106
93
|
}
|
|
107
94
|
}
|
|
108
95
|
export function setNotificationNameAndroid(name) {
|
|
109
96
|
if (isAndroid()) {
|
|
110
|
-
|
|
97
|
+
NativeGroupLinkSDK.setNotificationNameAndroid(name);
|
|
111
98
|
}
|
|
112
99
|
}
|
|
113
|
-
export function getNotificationNameAndroid() {
|
|
100
|
+
export async function getNotificationNameAndroid() {
|
|
114
101
|
if (isAndroid()) {
|
|
115
|
-
return
|
|
102
|
+
return NativeGroupLinkSDK.getNotificationNameAndroid();
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
export function setNotificationNameIOS(name) {
|
|
107
|
+
if (isiOS()) {
|
|
108
|
+
NativeGroupLinkSDK.setNotificationNameIOS(name);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export async function getNotificationNameIOS() {
|
|
112
|
+
if (isiOS()) {
|
|
113
|
+
return NativeGroupLinkSDK.getNotificationNameIOS();
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
export function setNotificationName(name) {
|
|
118
|
+
if (isAndroid()) {
|
|
119
|
+
NativeGroupLinkSDK.setNotificationNameAndroid(name);
|
|
120
|
+
}
|
|
121
|
+
if (isiOS()) {
|
|
122
|
+
NativeGroupLinkSDK.setNotificationNameIOS(name);
|
|
116
123
|
}
|
|
117
124
|
}
|
|
118
125
|
export function requestScheduleExactAlarmPermissionAndroid() {
|
|
119
126
|
if (isAndroid()) {
|
|
120
|
-
|
|
127
|
+
NativeGroupLinkSDK.requestScheduleExactAlarm();
|
|
121
128
|
}
|
|
122
129
|
}
|
|
123
|
-
|
|
124
|
-
// function getUserIDiOS(success: (userId: string) => void) {
|
|
125
|
-
// RNGroupLinkSDK.getUserID(success);
|
|
126
|
-
// }
|
|
127
|
-
|
|
128
|
-
// function success(userId: string): void {
|
|
129
|
-
// throw new Error('Function not implemented.');
|
|
130
|
-
// }
|
|
131
130
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["PermissionsAndroid","Platform","NativeGroupLinkSDK","getUserId","isAndroid","userID","getUserIdAndroid","Promise","resolve","reject","isiOS","getUserID","setFirebaseToken","token","startBluetoothIOS","setDevicePushTokenIOS","setDevicePushToken","startLocationIOS","OS","startGrouplink","withToken","debbugable","startIOS","startAndroid","startGrouplinkAndroid","startGrouplinkIOS","checkBluetoothIOS","startBluetoothAndroid","Version","bluetoothPermission","requestMultiple","PERMISSIONS","BLUETOOTH_SCAN","BLUETOOTH_ADVERTISE","BLUETOOTH_CONNECT","RESULTS","GRANTED","startLocationAndroid","locationPermission","ACCESS_FINE_LOCATION","ACCESS_COARSE_LOCATION","startLocation","startBluetooth","requestFullIntentPermissionAndroid","setNotificationNameAndroid","name","getNotificationNameAndroid","setNotificationNameIOS","getNotificationNameIOS","setNotificationName","requestScheduleExactAlarmPermissionAndroid","requestScheduleExactAlarm"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,kBAAkB,EAA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AAI1C,SAAS,CAAC,CAAC,EAAE;IACf,OAAOF,kBAAkB,CAAC4C,0BAA0B,CAAC,CAAC;EACxD;EACA,OAAO,IAAI;AACb;AAEA,OAAO,SAASC,sBAAsBA,CAACF,IAAY,EAAE;EACnD,IAAInC,KAAK,CAAC,CAAC,EAAE;IACXR,kBAAkB,CAAC6C,sBAAsB,CAACF,IAAI,CAAC;EACjD;AACF;AAEA,OAAO,eAAeG,sBAAsBA,CAAA,EAA2B;EACrE,IAAItC,KAAK,CAAC,CAAC,EAAE;IACX,OAAOR,kBAAkB,CAAC8C,sBAAsB,CAAC,CAAC;EACpD;EACA,OAAO,IAAI;AACb;AAEA,OAAO,SAASC,mBAAmBA,CAACJ,IAAY,EAAE;EAChD,IAAIzC,SAAS,CAAC,CAAC,EAAE;IACfF,kBAAkB,CAAC0C,0BAA0B,CAACC,IAAI,CAAC;EACrD;EACA,IAAInC,KAAK,CAAC,CAAC,EAAE;IACXR,kBAAkB,CAAC6C,sBAAsB,CAACF,IAAI,CAAC;EACjD;AACF;AAEA,OAAO,SAASK,0CAA0CA,CAAA,EAAG;EAC3D,IAAI9C,SAAS,CAAC,CAAC,EAAE;IACfF,kBAAkB,CAACiD,yBAAyB,CAAC,CAAC;EAChD;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
getUserIdAndroid(): Promise<string>;
|
|
4
|
+
startAndroid(token: string, debbugable: boolean): void;
|
|
5
|
+
setFirebaseToken(token: string): void;
|
|
6
|
+
requestFullIntentPermissionAndroid(): void;
|
|
7
|
+
setNotificationNameAndroid(notificationName: string): void;
|
|
8
|
+
getNotificationNameAndroid(): Promise<string>;
|
|
9
|
+
requestScheduleExactAlarm(): void;
|
|
10
|
+
getUserID(): Promise<string>;
|
|
11
|
+
setDevicePushToken(withPushToken: string): void;
|
|
12
|
+
startIOS(withToken: string): void;
|
|
13
|
+
startBluetoothIOS(): void;
|
|
14
|
+
checkBluetoothIOS(): void;
|
|
15
|
+
startLocationIOS(): void;
|
|
16
|
+
setNotificationNameIOS(withNotificationName: string): void;
|
|
17
|
+
getNotificationNameIOS(): Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: Spec;
|
|
20
|
+
export default _default;
|
|
21
|
+
//# sourceMappingURL=NativeGrouplinkSdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeGrouplinkSdk.d.ts","sourceRoot":"","sources":["../../src/NativeGrouplinkSdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IACvD,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,kCAAkC,IAAI,IAAI,CAAC;IAC3C,0BAA0B,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3D,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9C,yBAAyB,IAAI,IAAI,CAAC;IAGlC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iBAAiB,IAAI,IAAI,CAAC;IAC1B,iBAAiB,IAAI,IAAI,CAAC;IAC1B,gBAAgB,IAAI,IAAI,CAAC;IACzB,sBAAsB,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3D,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C;;AAED,wBAAwE"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
export declare function getUserId(): Promise<string | null>;
|
|
2
2
|
export declare function setFirebaseToken(token: string): void;
|
|
3
|
-
export declare function startBluetoothIOS():
|
|
4
|
-
export declare function setDevicePushTokenIOS(token: string):
|
|
5
|
-
export declare function startLocationIOS():
|
|
3
|
+
export declare function startBluetoothIOS(): void;
|
|
4
|
+
export declare function setDevicePushTokenIOS(token: string): void;
|
|
5
|
+
export declare function startLocationIOS(): void;
|
|
6
6
|
export declare function startGrouplink(withToken: string, debbugable: boolean): void;
|
|
7
7
|
export declare function startGrouplinkAndroid(withToken: string, debbugable: boolean): void;
|
|
8
8
|
export declare function startGrouplinkIOS(withToken: string): void;
|
|
9
|
-
export declare function checkBluetoothIOS():
|
|
9
|
+
export declare function checkBluetoothIOS(): void;
|
|
10
10
|
export declare function startBluetoothAndroid(): Promise<void>;
|
|
11
11
|
export declare function startLocationAndroid(): Promise<void>;
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
12
|
+
export declare function startLocation(): void;
|
|
13
|
+
export declare function startBluetooth(): void;
|
|
14
|
+
export declare function requestFullIntentPermissionAndroid(): void;
|
|
15
|
+
export declare function setNotificationNameAndroid(name: string): void;
|
|
16
|
+
export declare function getNotificationNameAndroid(): Promise<string | null>;
|
|
17
|
+
export declare function setNotificationNameIOS(name: string): void;
|
|
18
|
+
export declare function getNotificationNameIOS(): Promise<string | null>;
|
|
19
|
+
export declare function setNotificationName(name: string): void;
|
|
20
|
+
export declare function requestScheduleExactAlarmPermissionAndroid(): void;
|
|
16
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAaxD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,QAI7C;AAED,wBAAgB,iBAAiB,SAIhC;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,QAIlD;AAED,wBAAgB,gBAAgB,SAI/B;AAUD,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,QAOpE;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,QAI3E;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,QAIlD;AAED,wBAAgB,iBAAiB,SAIhC;AAED,wBAAsB,qBAAqB,kBAkB1C;AAED,wBAAsB,oBAAoB,kBAczC;AAED,wBAAgB,aAAa,SAI5B;AAED,wBAAgB,cAAc,SAI7B;AAED,wBAAgB,kCAAkC,SAIjD;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,QAItD;AAED,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKzE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,QAIlD;AAED,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKrE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,QAO/C;AAED,wBAAgB,0CAA0C,SAIzD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grouplinknetwork/rn-grouplink-sdk",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "Plugin for implementing the company's native sdk group link",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
7
|
"types": "lib/typescript/index.d.ts",
|
|
@@ -114,6 +114,14 @@
|
|
|
114
114
|
"trailingComma": "es5",
|
|
115
115
|
"useTabs": false
|
|
116
116
|
},
|
|
117
|
+
"codegenConfig": {
|
|
118
|
+
"name": "GrouplinkSdkSpec",
|
|
119
|
+
"type": "modules",
|
|
120
|
+
"jsSrcsDir": "src",
|
|
121
|
+
"android": {
|
|
122
|
+
"javaPackageName": "com.grouplinksdk"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
117
125
|
"react-native-builder-bob": {
|
|
118
126
|
"source": "src",
|
|
119
127
|
"output": "lib",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
// Android-only methods
|
|
6
|
+
getUserIdAndroid(): Promise<string>;
|
|
7
|
+
startAndroid(token: string, debbugable: boolean): void;
|
|
8
|
+
setFirebaseToken(token: string): void;
|
|
9
|
+
requestFullIntentPermissionAndroid(): void;
|
|
10
|
+
setNotificationNameAndroid(notificationName: string): void;
|
|
11
|
+
getNotificationNameAndroid(): Promise<string>;
|
|
12
|
+
requestScheduleExactAlarm(): void;
|
|
13
|
+
|
|
14
|
+
// iOS-only methods
|
|
15
|
+
getUserID(): Promise<string>;
|
|
16
|
+
setDevicePushToken(withPushToken: string): void;
|
|
17
|
+
startIOS(withToken: string): void;
|
|
18
|
+
startBluetoothIOS(): void;
|
|
19
|
+
checkBluetoothIOS(): void;
|
|
20
|
+
startLocationIOS(): void;
|
|
21
|
+
setNotificationNameIOS(withNotificationName: string): void;
|
|
22
|
+
getNotificationNameIOS(): Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('RNGroupLinkSDK');
|
package/src/index.tsx
CHANGED
|
@@ -1,165 +1,171 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const LINKING_ERROR =
|
|
4
|
-
`The package 'grouplink-sdk' 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 RNGroupLinkSDK = NativeModules.RNGroupLinkSDK
|
|
10
|
-
? NativeModules.RNGroupLinkSDK
|
|
11
|
-
: new Proxy(
|
|
12
|
-
{},
|
|
13
|
-
{
|
|
14
|
-
get() {
|
|
15
|
-
throw new Error(LINKING_ERROR);
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
);
|
|
1
|
+
import { PermissionsAndroid, Platform } from 'react-native';
|
|
2
|
+
import NativeGroupLinkSDK from './NativeGrouplinkSdk';
|
|
19
3
|
|
|
20
4
|
export async function getUserId(): Promise<string | null> {
|
|
21
5
|
if (isAndroid()) {
|
|
22
|
-
const userID: string = await
|
|
23
|
-
if (userID
|
|
6
|
+
const userID: string = await NativeGroupLinkSDK.getUserIdAndroid();
|
|
7
|
+
if (userID !== 'User not registered yet.') {
|
|
24
8
|
return Promise.resolve(userID);
|
|
25
9
|
} else {
|
|
26
|
-
return Promise.reject(
|
|
10
|
+
return Promise.reject('UserID not registered yet');
|
|
27
11
|
}
|
|
28
12
|
}
|
|
29
13
|
if (isiOS()) {
|
|
30
|
-
|
|
31
|
-
if (userID != null) {
|
|
32
|
-
return Promise.resolve(userID);
|
|
33
|
-
} else {
|
|
34
|
-
return Promise.reject("UserID not registered yet")
|
|
35
|
-
}
|
|
14
|
+
return NativeGroupLinkSDK.getUserID();
|
|
36
15
|
}
|
|
37
|
-
return Promise.reject(
|
|
16
|
+
return Promise.reject('Internal Error');
|
|
38
17
|
}
|
|
39
18
|
|
|
40
19
|
export function setFirebaseToken(token: string) {
|
|
41
20
|
if (isAndroid()) {
|
|
42
|
-
|
|
43
|
-
RNGroupLinkSDK.setFirebaseToken(token);
|
|
21
|
+
NativeGroupLinkSDK.setFirebaseToken(token);
|
|
44
22
|
}
|
|
45
23
|
}
|
|
46
24
|
|
|
47
25
|
export function startBluetoothIOS() {
|
|
48
26
|
if (isiOS()) {
|
|
49
|
-
|
|
50
|
-
return RNGroupLinkSDK.startBluetoothIOS();
|
|
27
|
+
NativeGroupLinkSDK.startBluetoothIOS();
|
|
51
28
|
}
|
|
52
|
-
return;
|
|
53
29
|
}
|
|
54
30
|
|
|
55
31
|
export function setDevicePushTokenIOS(token: string) {
|
|
56
|
-
|
|
32
|
+
if (isiOS()) {
|
|
33
|
+
NativeGroupLinkSDK.setDevicePushToken(token);
|
|
34
|
+
}
|
|
57
35
|
}
|
|
58
36
|
|
|
59
37
|
export function startLocationIOS() {
|
|
60
38
|
if (isiOS()) {
|
|
61
|
-
|
|
62
|
-
return RNGroupLinkSDK.startLocationIOS();
|
|
39
|
+
NativeGroupLinkSDK.startLocationIOS();
|
|
63
40
|
}
|
|
64
|
-
return;
|
|
65
41
|
}
|
|
66
42
|
|
|
67
43
|
function isAndroid() {
|
|
68
|
-
return Platform.OS
|
|
44
|
+
return Platform.OS === 'android';
|
|
69
45
|
}
|
|
70
46
|
|
|
71
47
|
function isiOS() {
|
|
72
|
-
return Platform.OS
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function startAndroid(withToken: string, debbugable: boolean) {
|
|
76
|
-
console.log('Group Link SDK (Android) - Start with token: ', withToken);
|
|
77
|
-
return RNGroupLinkSDK.startAndroid(withToken, debbugable);
|
|
78
|
-
}
|
|
79
|
-
function startIOS(withToken: string) {
|
|
80
|
-
console.log('Group Link SDK (IOS) - Start with token: ', withToken);
|
|
81
|
-
return RNGroupLinkSDK.startIOS(withToken);
|
|
48
|
+
return Platform.OS === 'ios';
|
|
82
49
|
}
|
|
83
50
|
|
|
84
51
|
export function startGrouplink(withToken: string, debbugable: boolean) {
|
|
85
52
|
if (isiOS()) {
|
|
86
|
-
startIOS(withToken);
|
|
53
|
+
NativeGroupLinkSDK.startIOS(withToken);
|
|
87
54
|
}
|
|
88
55
|
if (isAndroid()) {
|
|
89
|
-
startAndroid(withToken, debbugable);
|
|
56
|
+
NativeGroupLinkSDK.startAndroid(withToken, debbugable);
|
|
90
57
|
}
|
|
91
58
|
}
|
|
92
59
|
|
|
93
60
|
export function startGrouplinkAndroid(withToken: string, debbugable: boolean) {
|
|
94
61
|
if (isAndroid()) {
|
|
95
|
-
startAndroid(withToken, debbugable);
|
|
62
|
+
NativeGroupLinkSDK.startAndroid(withToken, debbugable);
|
|
96
63
|
}
|
|
97
64
|
}
|
|
98
65
|
|
|
99
66
|
export function startGrouplinkIOS(withToken: string) {
|
|
100
67
|
if (isiOS()) {
|
|
101
|
-
startIOS(withToken);
|
|
68
|
+
NativeGroupLinkSDK.startIOS(withToken);
|
|
102
69
|
}
|
|
103
70
|
}
|
|
104
71
|
|
|
105
72
|
export function checkBluetoothIOS() {
|
|
106
|
-
if (isiOS())
|
|
107
|
-
|
|
73
|
+
if (isiOS()) {
|
|
74
|
+
NativeGroupLinkSDK.checkBluetoothIOS();
|
|
75
|
+
}
|
|
108
76
|
}
|
|
77
|
+
|
|
109
78
|
export async function startBluetoothAndroid() {
|
|
110
|
-
if (!(Platform.OS ===
|
|
111
|
-
|
|
79
|
+
if (!(Platform.OS === 'android' && Platform.Version >= 31)) return;
|
|
80
|
+
|
|
112
81
|
const bluetoothPermission = await PermissionsAndroid.requestMultiple([
|
|
113
82
|
PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN!,
|
|
114
83
|
PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE!,
|
|
115
|
-
PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
84
|
+
PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT!,
|
|
85
|
+
]);
|
|
86
|
+
if (
|
|
87
|
+
bluetoothPermission['android.permission.BLUETOOTH_SCAN'] ===
|
|
88
|
+
PermissionsAndroid.RESULTS.GRANTED &&
|
|
89
|
+
bluetoothPermission['android.permission.BLUETOOTH_ADVERTISE'] ===
|
|
90
|
+
PermissionsAndroid.RESULTS.GRANTED &&
|
|
91
|
+
bluetoothPermission['android.permission.BLUETOOTH_CONNECT'] ===
|
|
92
|
+
PermissionsAndroid.RESULTS.GRANTED
|
|
93
|
+
) {
|
|
94
|
+
NativeGroupLinkSDK.startAndroid('', false);
|
|
119
95
|
}
|
|
120
|
-
}
|
|
96
|
+
}
|
|
97
|
+
|
|
121
98
|
export async function startLocationAndroid() {
|
|
122
|
-
if (!(Platform.OS
|
|
99
|
+
if (!(Platform.OS === 'android' && Platform.Version >= 23)) return;
|
|
123
100
|
const locationPermission = await PermissionsAndroid.requestMultiple([
|
|
124
101
|
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION!,
|
|
125
|
-
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION
|
|
126
|
-
|
|
127
|
-
|
|
102
|
+
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION!,
|
|
103
|
+
]);
|
|
104
|
+
if (
|
|
105
|
+
locationPermission['android.permission.ACCESS_COARSE_LOCATION'] ===
|
|
106
|
+
PermissionsAndroid.RESULTS.GRANTED &&
|
|
107
|
+
locationPermission['android.permission.ACCESS_FINE_LOCATION'] ===
|
|
108
|
+
PermissionsAndroid.RESULTS.GRANTED
|
|
128
109
|
) {
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
110
|
+
// Permissions granted
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function startLocation() {
|
|
115
|
+
if (isiOS()) {
|
|
116
|
+
NativeGroupLinkSDK.startLocationIOS();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function startBluetooth() {
|
|
121
|
+
if (isiOS()) {
|
|
122
|
+
NativeGroupLinkSDK.startBluetoothIOS();
|
|
132
123
|
}
|
|
133
124
|
}
|
|
134
125
|
|
|
135
126
|
export function requestFullIntentPermissionAndroid() {
|
|
136
127
|
if (isAndroid()) {
|
|
137
|
-
|
|
128
|
+
NativeGroupLinkSDK.requestFullIntentPermissionAndroid();
|
|
138
129
|
}
|
|
139
130
|
}
|
|
140
131
|
|
|
141
|
-
export function setNotificationNameAndroid(name:string) {
|
|
132
|
+
export function setNotificationNameAndroid(name: string) {
|
|
142
133
|
if (isAndroid()) {
|
|
143
|
-
|
|
134
|
+
NativeGroupLinkSDK.setNotificationNameAndroid(name);
|
|
144
135
|
}
|
|
145
136
|
}
|
|
146
137
|
|
|
147
|
-
export function getNotificationNameAndroid() {
|
|
138
|
+
export async function getNotificationNameAndroid(): Promise<string | null> {
|
|
148
139
|
if (isAndroid()) {
|
|
149
|
-
return
|
|
140
|
+
return NativeGroupLinkSDK.getNotificationNameAndroid();
|
|
150
141
|
}
|
|
142
|
+
return null;
|
|
151
143
|
}
|
|
152
144
|
|
|
153
|
-
export function
|
|
154
|
-
if (
|
|
155
|
-
|
|
145
|
+
export function setNotificationNameIOS(name: string) {
|
|
146
|
+
if (isiOS()) {
|
|
147
|
+
NativeGroupLinkSDK.setNotificationNameIOS(name);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export async function getNotificationNameIOS(): Promise<string | null> {
|
|
152
|
+
if (isiOS()) {
|
|
153
|
+
return NativeGroupLinkSDK.getNotificationNameIOS();
|
|
156
154
|
}
|
|
155
|
+
return null;
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
export function setNotificationName(name: string) {
|
|
159
|
+
if (isAndroid()) {
|
|
160
|
+
NativeGroupLinkSDK.setNotificationNameAndroid(name);
|
|
161
|
+
}
|
|
162
|
+
if (isiOS()) {
|
|
163
|
+
NativeGroupLinkSDK.setNotificationNameIOS(name);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
162
166
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
export function requestScheduleExactAlarmPermissionAndroid() {
|
|
168
|
+
if (isAndroid()) {
|
|
169
|
+
NativeGroupLinkSDK.requestScheduleExactAlarm();
|
|
170
|
+
}
|
|
171
|
+
}
|
package/ios/GrouplinkSdk.m
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
|
|
3
|
-
@interface RCT_EXTERN_MODULE(RNGroupLinkSDK, NSObject)
|
|
4
|
-
|
|
5
|
-
RCT_EXTERN_METHOD(startBluetoothIOS)
|
|
6
|
-
RCT_EXTERN_METHOD(checkBluetoothIOS)
|
|
7
|
-
RCT_EXTERN_METHOD(startLocationIOS)
|
|
8
|
-
RCT_EXTERN_METHOD(setDevicePushToken:(NSString)withPushToken)
|
|
9
|
-
RCT_EXTERN_METHOD(startIOS:(NSString)withToken)
|
|
10
|
-
RCT_EXTERN_METHOD(getUserID:
|
|
11
|
-
(RCTPromiseResolveBlock)resolve
|
|
12
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
13
|
-
|
|
14
|
-
+ (BOOL)requiresMainQueueSetup
|
|
15
|
-
{
|
|
16
|
-
return YES;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@end
|
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>SchemeUserState</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>GrouplinkSdk.xcscheme_^#shared#^_</key>
|
|
8
|
-
<dict>
|
|
9
|
-
<key>orderHint</key>
|
|
10
|
-
<integer>0</integer>
|
|
11
|
-
</dict>
|
|
12
|
-
</dict>
|
|
13
|
-
</dict>
|
|
14
|
-
</plist>
|