vibes-react-native 1.1.0 → 1.1.2
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/.gradle/6.8/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.8/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.8/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/src/main/java/com/vibes/push/rn/plugin/notifications/Fms.java +98 -82
- package/lib/commonjs/index.js +1 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
@@ -1,114 +1,130 @@
|
|
|
1
1
|
package com.vibes.push.rn.plugin.notifications;
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import static com.vibes.push.rn.plugin.VibesModule.DEVICE_REGISTERED;
|
|
4
|
+
import static com.vibes.push.rn.plugin.VibesModule.TAG;
|
|
5
|
+
import static com.vibes.push.rn.plugin.VibesModule.TOKEN_KEY;
|
|
6
|
+
import static com.vibes.push.rn.plugin.VibesModule.VIBES_APIURL_KEY;
|
|
7
|
+
import static com.vibes.push.rn.plugin.VibesModule.VIBES_APPID_KEY;
|
|
8
|
+
|
|
4
9
|
import android.content.SharedPreferences;
|
|
10
|
+
import android.content.pm.ApplicationInfo;
|
|
11
|
+
import android.content.pm.PackageManager;
|
|
5
12
|
import android.os.Bundle;
|
|
6
|
-
import android.preference.PreferenceManager;
|
|
7
|
-
import android.util.Log;
|
|
8
13
|
import android.os.Handler;
|
|
9
14
|
import android.os.Looper;
|
|
15
|
+
import android.preference.PreferenceManager;
|
|
16
|
+
import android.util.Log;
|
|
10
17
|
|
|
18
|
+
import com.facebook.react.ReactApplication;
|
|
19
|
+
import com.facebook.react.ReactInstanceManager;
|
|
20
|
+
import com.facebook.react.bridge.ReactContext;
|
|
11
21
|
import com.google.firebase.messaging.FirebaseMessagingService;
|
|
12
22
|
import com.google.firebase.messaging.RemoteMessage;
|
|
13
|
-
import com.vibes.
|
|
23
|
+
import com.vibes.push.rn.plugin.PushEvtEmitter;
|
|
24
|
+
import com.vibes.push.rn.plugin.VibesModule;
|
|
14
25
|
import com.vibes.vibes.PushPayloadParser;
|
|
15
26
|
import com.vibes.vibes.Vibes;
|
|
16
|
-
|
|
17
|
-
import com.facebook.react.ReactApplication;
|
|
18
|
-
import com.facebook.react.ReactInstanceManager;
|
|
19
|
-
import com.facebook.react.bridge.ReactContext;
|
|
27
|
+
import com.vibes.vibes.VibesConfig;
|
|
20
28
|
|
|
21
29
|
import java.util.Map;
|
|
22
|
-
import com.vibes.push.rn.plugin.VibesModule;
|
|
23
|
-
import com.vibes.push.rn.plugin.PushEvtEmitter;
|
|
24
|
-
import static com.vibes.push.rn.plugin.VibesModule.TAG;
|
|
25
|
-
import static com.vibes.push.rn.plugin.VibesModule.TOKEN_KEY;
|
|
26
|
-
import static com.vibes.push.rn.plugin.VibesModule.DEVICE_REGISTERED;
|
|
27
30
|
|
|
28
31
|
public class Fms extends FirebaseMessagingService {
|
|
32
|
+
private PushPayloadParser pushModel;
|
|
33
|
+
private RemoteMessage message;
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
@Override
|
|
36
|
+
public void onMessageReceived(RemoteMessage message) {
|
|
37
|
+
Log.d(TAG, "Push message received. Processing");
|
|
38
|
+
this.message = message;
|
|
39
|
+
this.pushModel = createPushPayloadParser(message.getData());
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
if (!initializeVibes()) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
handleNotification(pushModel, message);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
public void onNewToken(String pushToken) {
|
|
49
|
+
super.onNewToken(pushToken);
|
|
50
|
+
Log.d(TAG, "Firebase token obtained from Fms as " + pushToken);
|
|
51
|
+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
52
|
+
preferences.edit().putString(TOKEN_KEY, pushToken).apply();
|
|
53
|
+
|
|
54
|
+
if (preferences.getBoolean(DEVICE_REGISTERED, false)) {
|
|
55
|
+
VibesModule.registerPush(pushToken);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private boolean initializeVibes() {
|
|
60
|
+
try {
|
|
61
|
+
Vibes.getInstance();
|
|
62
|
+
return true;
|
|
63
|
+
} catch (Exception e) {
|
|
64
|
+
initializeVibesAsync();
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private void initializeVibesAsync() {
|
|
70
|
+
ApplicationInfo ai;
|
|
71
|
+
try {
|
|
72
|
+
ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
|
|
73
|
+
} catch (PackageManager.NameNotFoundException e) {
|
|
74
|
+
Log.e(TAG, "Failed to get application info", e);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Bundle bundle = ai.metaData;
|
|
79
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
80
|
+
String appId = bundle.getString(VIBES_APPID_KEY);
|
|
81
|
+
String apiUrl = bundle.getString(VIBES_APIURL_KEY);
|
|
82
|
+
|
|
83
|
+
VibesConfig config = new VibesConfig.Builder()
|
|
84
|
+
.setAppId(appId)
|
|
85
|
+
.setApiUrl(apiUrl != null && !apiUrl.isEmpty() ? apiUrl : null)
|
|
86
|
+
.build();
|
|
87
|
+
Log.d(TAG, "Initializing Vibes with appId=[" + appId + "] and apiUrl=[" + apiUrl + "]");
|
|
88
|
+
Vibes.initialize(this, config);
|
|
89
|
+
handleNotification(pushModel, message);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private void handleNotification(PushPayloadParser pushModel, RemoteMessage message) {
|
|
94
|
+
new Thread(() -> {
|
|
41
95
|
try {
|
|
42
96
|
Vibes.getInstance().handleNotification(getApplicationContext(), message.getData());
|
|
43
97
|
if (!pushModel.isSilentPush()) {
|
|
44
98
|
emitPayload(pushModel);
|
|
45
99
|
}
|
|
46
|
-
} catch(
|
|
47
|
-
|
|
48
|
-
handler.post(new Runnable() {
|
|
49
|
-
public void run() {
|
|
50
|
-
Vibes.getInstance().handleNotification(getApplicationContext(), message.getData());
|
|
51
|
-
if (!pushModel.isSilentPush()) {
|
|
52
|
-
emitPayload(pushModel);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
100
|
+
} catch (Exception e) {
|
|
101
|
+
Log.e(TAG, "Error handling notification", e);
|
|
56
102
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
* This is invoked everytime the application generates a new Firebase push
|
|
60
|
-
* token, which is then sent to the Vibes server to be able to target this
|
|
61
|
-
* device with push messages.
|
|
62
|
-
*
|
|
63
|
-
* @param pushToken
|
|
64
|
-
*/
|
|
65
|
-
@Override
|
|
66
|
-
public void onNewToken(String pushToken) {
|
|
67
|
-
super.onNewToken(pushToken);
|
|
68
|
-
Log.d(TAG, "Firebase token obtained from Fms as " + pushToken);
|
|
69
|
-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
70
|
-
SharedPreferences.Editor editor = preferences.edit();
|
|
71
|
-
editor.putString(TOKEN_KEY, pushToken);
|
|
72
|
-
editor.apply();
|
|
73
|
-
|
|
74
|
-
boolean registered = preferences.getBoolean(DEVICE_REGISTERED, false);
|
|
75
|
-
if (registered) {
|
|
76
|
-
VibesModule.registerPush(pushToken);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
103
|
+
}).start();
|
|
104
|
+
}
|
|
79
105
|
|
|
80
106
|
public PushPayloadParser createPushPayloadParser(Map<String, String> map) {
|
|
81
107
|
return new PushPayloadParser(map);
|
|
82
108
|
}
|
|
83
109
|
|
|
84
110
|
private void emitPayload(PushPayloadParser pushModel) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
mReactInstanceManager.
|
|
102
|
-
public void onReactContextInitialized(ReactContext context) {
|
|
103
|
-
PushEvtEmitter pushEmitter = new PushEvtEmitter(context);
|
|
104
|
-
pushEmitter.notifyPushReceived(pushModel);
|
|
105
|
-
mReactInstanceManager.removeReactInstanceEventListener(this);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
|
|
109
|
-
// Construct it in the background
|
|
110
|
-
mReactInstanceManager.createReactContextInBackground();
|
|
111
|
-
}
|
|
111
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
112
|
+
ReactInstanceManager mReactInstanceManager = ((ReactApplication) getApplication()).getReactNativeHost()
|
|
113
|
+
.getReactInstanceManager();
|
|
114
|
+
ReactContext context = mReactInstanceManager.getCurrentReactContext();
|
|
115
|
+
if (context != null) {
|
|
116
|
+
new PushEvtEmitter(context).notifyPushReceived(pushModel);
|
|
117
|
+
} else {
|
|
118
|
+
mReactInstanceManager
|
|
119
|
+
.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
|
|
120
|
+
@Override
|
|
121
|
+
public void onReactContextInitialized(ReactContext context) {
|
|
122
|
+
new PushEvtEmitter(context).notifyPushReceived(pushModel);
|
|
123
|
+
mReactInstanceManager.removeReactInstanceEventListener(this);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
|
|
127
|
+
mReactInstanceManager.createReactContextInBackground();
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
130
|
});
|
package/lib/commonjs/index.js
CHANGED
|
@@ -159,6 +159,5 @@ function onInboxMessageOpen(inboxMap) {
|
|
|
159
159
|
function onInboxMessagesFetched() {
|
|
160
160
|
return Vibes.onInboxMessagesFetched();
|
|
161
161
|
}
|
|
162
|
-
var _default = Vibes;
|
|
163
|
-
exports.default = _default;
|
|
162
|
+
var _default = exports.default = Vibes;
|
|
164
163
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","Vibes","NativeModules","Proxy","get","Error","registerDevice","unregisterDevice","registerPush","unregisterPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId","getPerson","fetchInboxMessages","fetchInboxMessage","message_uid","markInboxMessageAsRead","expireInboxMessage","onInboxMessageOpen","inboxMap","onInboxMessagesFetched"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Vibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport interface DeviceResponse {\n device_id?: string;\n}\nexport interface DeviceInfoResponse extends DeviceResponse {\n push_token?: string;\n}\n\nexport interface PersonResponse {\n person_key?: string;\n external_person_id?: string;\n}\n\nexport interface InboxMessage {\n content?: string;\n created_at?: string;\n expires_at?: string;\n message_uid?: string;\n read?: boolean;\n subject?: string;\n detail?: string;\n collapse_key?: string;\n apprefdata?: any;\n images?: any;\n inbox_custom_data: any;\n}\n\n/**\n * Register this device with the Vibes platform\n *\n * @return {Promise<DeviceResponse>}\n */\nexport function registerDevice(): Promise<DeviceResponse> {\n return Vibes.registerDevice();\n}\n/**\n * Unregister this device with the Vibes platform\n *\n * @return {Promise<void>}\n */\nexport function unregisterDevice(): Promise<void> {\n return Vibes.unregisterDevice();\n}\n\n/**\n * Register this device to receive push notifications\n *\n * @return {Promise<void>}\n */\nexport function registerPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n* Unregister the device from receiving push notifications\n*\n* @return {Promise<void>}\n*/\nexport function unregisterPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token\n *\n * @return {Promise<DeviceInfoResponse>}\n */\nexport function getVibesDeviceInfo(): Promise<DeviceInfoResponse> {\n return Vibes.getVibesDeviceInfo();\n}\n\n/**\n * Updates the Vibes platform with changes to the device since the last time device information was submitted.\n *\n * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.\n * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @returns {Promise<void>}\n */\nexport function updateDevice(\n updateCredential: boolean,\n latitude: number,\n longitude: number\n): Promise<void> {\n return Vibes.updateDevice(updateCredential, latitude, longitude);\n}\n\n/**\n * Associate an external ID with the current person.\n *\n * @param {string} externalPersonId\n * @return {Promise<void>}\n */\nexport function associatePerson(externalPersonId: string): Promise<void> {\n return Vibes.associatePerson(externalPersonId);\n}\n\n/**\n * Fetches the PersonResponse associated with this device currently\n *\n * @return {Promise<PersonResponse>}\n */\nexport function getPerson(): Promise<PersonResponse> {\n return Vibes.getPerson();\n}\n/**\n * Fetches an array of inbox messages for the person associated with this device.\n *\n * @return {Promise<InboxMessage[]>}\n */\nexport function fetchInboxMessages(): Promise<InboxMessage[]> {\n return Vibes.fetchInboxMessages();\n}\n\n/**\n * Fetches a single inbox message by it's id.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>}\n */\nexport function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.fetchInboxMessage(message_uid);\n}\n\n/**\n * Marks an inbox message as read.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated\n */\nexport function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {\n return Vibes.markInboxMessageAsRead(message_uid);\n}\n\n/**\n * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated\n */\nexport function expireInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.expireInboxMessage(message_uid);\n}\n\n/**\n * Records an event for when the user opens an inbox message.\n *\n * @param inboxMap json map of the InboxMessage\n * @return {Promise<void>}\n */\nexport function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {\n return Vibes.onInboxMessageOpen(inboxMap);\n}\n\n/**\n * Records an event for when the user fetches a list of inbox messages.\n *\n * @return {Promise<void>}\n */\nexport function onInboxMessagesFetched(): Promise<void> {\n return Vibes.onInboxMessagesFetched();\n}\n\nexport default Vibes;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAEA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","Vibes","NativeModules","Proxy","get","Error","registerDevice","unregisterDevice","registerPush","unregisterPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId","getPerson","fetchInboxMessages","fetchInboxMessage","message_uid","markInboxMessageAsRead","expireInboxMessage","onInboxMessageOpen","inboxMap","onInboxMessagesFetched","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Vibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport interface DeviceResponse {\n device_id?: string;\n}\nexport interface DeviceInfoResponse extends DeviceResponse {\n push_token?: string;\n}\n\nexport interface PersonResponse {\n person_key?: string;\n external_person_id?: string;\n}\n\nexport interface InboxMessage {\n content?: string;\n created_at?: string;\n expires_at?: string;\n message_uid?: string;\n read?: boolean;\n subject?: string;\n detail?: string;\n collapse_key?: string;\n apprefdata?: any;\n images?: any;\n inbox_custom_data: any;\n}\n\n/**\n * Register this device with the Vibes platform\n *\n * @return {Promise<DeviceResponse>}\n */\nexport function registerDevice(): Promise<DeviceResponse> {\n return Vibes.registerDevice();\n}\n/**\n * Unregister this device with the Vibes platform\n *\n * @return {Promise<void>}\n */\nexport function unregisterDevice(): Promise<void> {\n return Vibes.unregisterDevice();\n}\n\n/**\n * Register this device to receive push notifications\n *\n * @return {Promise<void>}\n */\nexport function registerPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n* Unregister the device from receiving push notifications\n*\n* @return {Promise<void>}\n*/\nexport function unregisterPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token\n *\n * @return {Promise<DeviceInfoResponse>}\n */\nexport function getVibesDeviceInfo(): Promise<DeviceInfoResponse> {\n return Vibes.getVibesDeviceInfo();\n}\n\n/**\n * Updates the Vibes platform with changes to the device since the last time device information was submitted.\n *\n * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.\n * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @returns {Promise<void>}\n */\nexport function updateDevice(\n updateCredential: boolean,\n latitude: number,\n longitude: number\n): Promise<void> {\n return Vibes.updateDevice(updateCredential, latitude, longitude);\n}\n\n/**\n * Associate an external ID with the current person.\n *\n * @param {string} externalPersonId\n * @return {Promise<void>}\n */\nexport function associatePerson(externalPersonId: string): Promise<void> {\n return Vibes.associatePerson(externalPersonId);\n}\n\n/**\n * Fetches the PersonResponse associated with this device currently\n *\n * @return {Promise<PersonResponse>}\n */\nexport function getPerson(): Promise<PersonResponse> {\n return Vibes.getPerson();\n}\n/**\n * Fetches an array of inbox messages for the person associated with this device.\n *\n * @return {Promise<InboxMessage[]>}\n */\nexport function fetchInboxMessages(): Promise<InboxMessage[]> {\n return Vibes.fetchInboxMessages();\n}\n\n/**\n * Fetches a single inbox message by it's id.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>}\n */\nexport function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.fetchInboxMessage(message_uid);\n}\n\n/**\n * Marks an inbox message as read.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated\n */\nexport function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {\n return Vibes.markInboxMessageAsRead(message_uid);\n}\n\n/**\n * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated\n */\nexport function expireInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.expireInboxMessage(message_uid);\n}\n\n/**\n * Records an event for when the user opens an inbox message.\n *\n * @param inboxMap json map of the InboxMessage\n * @return {Promise<void>}\n */\nexport function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {\n return Vibes.onInboxMessageOpen(inboxMap);\n}\n\n/**\n * Records an event for when the user fetches a list of inbox messages.\n *\n * @return {Promise<void>}\n */\nexport function onInboxMessagesFetched(): Promise<void> {\n return Vibes.onInboxMessagesFetched();\n}\n\nexport default Vibes;\n"],"mappings":"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"}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Vibes","Proxy","get","Error","registerDevice","unregisterDevice","registerPush","unregisterPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId","getPerson","fetchInboxMessages","fetchInboxMessage","message_uid","markInboxMessageAsRead","expireInboxMessage","onInboxMessageOpen","inboxMap","onInboxMessagesFetched"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Vibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport interface DeviceResponse {\n device_id?: string;\n}\nexport interface DeviceInfoResponse extends DeviceResponse {\n push_token?: string;\n}\n\nexport interface PersonResponse {\n person_key?: string;\n external_person_id?: string;\n}\n\nexport interface InboxMessage {\n content?: string;\n created_at?: string;\n expires_at?: string;\n message_uid?: string;\n read?: boolean;\n subject?: string;\n detail?: string;\n collapse_key?: string;\n apprefdata?: any;\n images?: any;\n inbox_custom_data: any;\n}\n\n/**\n * Register this device with the Vibes platform\n *\n * @return {Promise<DeviceResponse>}\n */\nexport function registerDevice(): Promise<DeviceResponse> {\n return Vibes.registerDevice();\n}\n/**\n * Unregister this device with the Vibes platform\n *\n * @return {Promise<void>}\n */\nexport function unregisterDevice(): Promise<void> {\n return Vibes.unregisterDevice();\n}\n\n/**\n * Register this device to receive push notifications\n *\n * @return {Promise<void>}\n */\nexport function registerPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n* Unregister the device from receiving push notifications\n*\n* @return {Promise<void>}\n*/\nexport function unregisterPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token\n *\n * @return {Promise<DeviceInfoResponse>}\n */\nexport function getVibesDeviceInfo(): Promise<DeviceInfoResponse> {\n return Vibes.getVibesDeviceInfo();\n}\n\n/**\n * Updates the Vibes platform with changes to the device since the last time device information was submitted.\n *\n * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.\n * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @returns {Promise<void>}\n */\nexport function updateDevice(\n updateCredential: boolean,\n latitude: number,\n longitude: number\n): Promise<void> {\n return Vibes.updateDevice(updateCredential, latitude, longitude);\n}\n\n/**\n * Associate an external ID with the current person.\n *\n * @param {string} externalPersonId\n * @return {Promise<void>}\n */\nexport function associatePerson(externalPersonId: string): Promise<void> {\n return Vibes.associatePerson(externalPersonId);\n}\n\n/**\n * Fetches the PersonResponse associated with this device currently\n *\n * @return {Promise<PersonResponse>}\n */\nexport function getPerson(): Promise<PersonResponse> {\n return Vibes.getPerson();\n}\n/**\n * Fetches an array of inbox messages for the person associated with this device.\n *\n * @return {Promise<InboxMessage[]>}\n */\nexport function fetchInboxMessages(): Promise<InboxMessage[]> {\n return Vibes.fetchInboxMessages();\n}\n\n/**\n * Fetches a single inbox message by it's id.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>}\n */\nexport function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.fetchInboxMessage(message_uid);\n}\n\n/**\n * Marks an inbox message as read.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated\n */\nexport function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {\n return Vibes.markInboxMessageAsRead(message_uid);\n}\n\n/**\n * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated\n */\nexport function expireInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.expireInboxMessage(message_uid);\n}\n\n/**\n * Records an event for when the user opens an inbox message.\n *\n * @param inboxMap json map of the InboxMessage\n * @return {Promise<void>}\n */\nexport function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {\n return Vibes.onInboxMessageOpen(inboxMap);\n}\n\n/**\n * Records an event for when the user fetches a list of inbox messages.\n *\n * @return {Promise<void>}\n */\nexport function onInboxMessagesFetched(): Promise<void> {\n return Vibes.onInboxMessagesFetched();\n}\n\nexport default Vibes;\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GAChB,6EAA4E,GAC7ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,KAAK,GAAGN,aAAa,CAACM,KAAK,GAC7BN,aAAa,CAACM,KAAK,GACnB,IAAIC,KAAK,CACT,CAAC,CAAC,EACF;EACEC,
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Vibes","Proxy","get","Error","registerDevice","unregisterDevice","registerPush","unregisterPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId","getPerson","fetchInboxMessages","fetchInboxMessage","message_uid","markInboxMessageAsRead","expireInboxMessage","onInboxMessageOpen","inboxMap","onInboxMessagesFetched"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Vibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport interface DeviceResponse {\n device_id?: string;\n}\nexport interface DeviceInfoResponse extends DeviceResponse {\n push_token?: string;\n}\n\nexport interface PersonResponse {\n person_key?: string;\n external_person_id?: string;\n}\n\nexport interface InboxMessage {\n content?: string;\n created_at?: string;\n expires_at?: string;\n message_uid?: string;\n read?: boolean;\n subject?: string;\n detail?: string;\n collapse_key?: string;\n apprefdata?: any;\n images?: any;\n inbox_custom_data: any;\n}\n\n/**\n * Register this device with the Vibes platform\n *\n * @return {Promise<DeviceResponse>}\n */\nexport function registerDevice(): Promise<DeviceResponse> {\n return Vibes.registerDevice();\n}\n/**\n * Unregister this device with the Vibes platform\n *\n * @return {Promise<void>}\n */\nexport function unregisterDevice(): Promise<void> {\n return Vibes.unregisterDevice();\n}\n\n/**\n * Register this device to receive push notifications\n *\n * @return {Promise<void>}\n */\nexport function registerPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n* Unregister the device from receiving push notifications\n*\n* @return {Promise<void>}\n*/\nexport function unregisterPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token\n *\n * @return {Promise<DeviceInfoResponse>}\n */\nexport function getVibesDeviceInfo(): Promise<DeviceInfoResponse> {\n return Vibes.getVibesDeviceInfo();\n}\n\n/**\n * Updates the Vibes platform with changes to the device since the last time device information was submitted.\n *\n * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.\n * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @returns {Promise<void>}\n */\nexport function updateDevice(\n updateCredential: boolean,\n latitude: number,\n longitude: number\n): Promise<void> {\n return Vibes.updateDevice(updateCredential, latitude, longitude);\n}\n\n/**\n * Associate an external ID with the current person.\n *\n * @param {string} externalPersonId\n * @return {Promise<void>}\n */\nexport function associatePerson(externalPersonId: string): Promise<void> {\n return Vibes.associatePerson(externalPersonId);\n}\n\n/**\n * Fetches the PersonResponse associated with this device currently\n *\n * @return {Promise<PersonResponse>}\n */\nexport function getPerson(): Promise<PersonResponse> {\n return Vibes.getPerson();\n}\n/**\n * Fetches an array of inbox messages for the person associated with this device.\n *\n * @return {Promise<InboxMessage[]>}\n */\nexport function fetchInboxMessages(): Promise<InboxMessage[]> {\n return Vibes.fetchInboxMessages();\n}\n\n/**\n * Fetches a single inbox message by it's id.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>}\n */\nexport function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.fetchInboxMessage(message_uid);\n}\n\n/**\n * Marks an inbox message as read.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated\n */\nexport function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {\n return Vibes.markInboxMessageAsRead(message_uid);\n}\n\n/**\n * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated\n */\nexport function expireInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.expireInboxMessage(message_uid);\n}\n\n/**\n * Records an event for when the user opens an inbox message.\n *\n * @param inboxMap json map of the InboxMessage\n * @return {Promise<void>}\n */\nexport function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {\n return Vibes.onInboxMessageOpen(inboxMap);\n}\n\n/**\n * Records an event for when the user fetches a list of inbox messages.\n *\n * @return {Promise<void>}\n */\nexport function onInboxMessagesFetched(): Promise<void> {\n return Vibes.onInboxMessagesFetched();\n}\n\nexport default Vibes;\n"],"mappings":"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"}
|