pushwoosh-react-native-plugin 6.1.27 → 6.1.28

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.
@@ -58,6 +58,7 @@ body:
58
58
  label: Your Pushwoosh React Native Plugin version
59
59
  description: Your React Native Plugin version which was integrated to the app. You may find it on the [releases page](https://github.com/Pushwoosh/pushwoosh-react-native-plugin/releases)
60
60
  options:
61
+ - 6.1.28
61
62
  - 6.1.26
62
63
  - 6.1.25
63
64
  - 6.1.23
package/index.js CHANGED
@@ -127,6 +127,55 @@ class PushNotification {
127
127
  PushwooshModule.onPushOpen(callback);
128
128
  }
129
129
 
130
+ //Function: setUserEmails
131
+ //Register emails list associated to the current user.
132
+ //
133
+ //Example:
134
+ //(start code)
135
+ // Pushwoosh.setUserEmails("someUser", ["example@mail.some"],
136
+ // function(status) {
137
+ // console.warn('setUserEmails success');
138
+ // },
139
+ // function(status) {
140
+ // console.warn('setUserEmails failed');
141
+ // }
142
+ // );
143
+ //
144
+ setUserEmails(userId: string, emails: Object, success: ?Function, fail: ?Function) {
145
+ if (!success) {
146
+ success = function() {};
147
+ }
148
+ if (!fail) {
149
+ fail = function(error) {};
150
+ }
151
+ PushwooshModule.setUserEmails(userId, emails, success, fail);
152
+ }
153
+
154
+
155
+ //Function: setEmails
156
+ //Register emails list associated to the current user.
157
+ //
158
+ //Example:
159
+ //(start code)
160
+ // Pushwoosh.setEmails(["example@mail.some"],
161
+ // function(status) {
162
+ // console.warn('setEmails success');
163
+ // },
164
+ // function(status) {
165
+ // console.warn('setEmails failed');
166
+ // }
167
+ // );
168
+ //
169
+ setEmails(emails: Object, success: ?Function, fail: ?Function) {
170
+ if (!success) {
171
+ success = function() {};
172
+ }
173
+ if (!fail) {
174
+ fail = function(error) {};
175
+ }
176
+ PushwooshModule.setEmails(emails, success, fail);
177
+ }
178
+
130
179
  //Function: setTags
131
180
  //Call this to set tags for the device
132
181
  //
@@ -233,6 +282,17 @@ class PushNotification {
233
282
  PushwooshModule.getHwid(success);
234
283
  }
235
284
 
285
+ //Function: getUserId
286
+ //Call this to get Pushwoosh User ID used for communications with Pushwoosh API
287
+ //
288
+ //Example:
289
+ //(start code)
290
+ // Pushwoosh.getUserId();
291
+ //(end)
292
+ getUserId(success: Function) {
293
+ PushwooshModule.getUserId(success);
294
+ }
295
+
236
296
  //Function: setUserId
237
297
  //[android, ios] Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
238
298
  //This allows data and events to be matched across multiple user devices.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushwoosh-react-native-plugin",
3
- "version": "6.1.27",
3
+ "version": "6.1.28",
4
4
  "description": "This plugin allows you to send and receive push notifications. Powered by Pushwoosh (www.pushwoosh.com).",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = "pushwoosh-react-native-plugin"
3
- s.version = "6.1.27"
3
+ s.version = "6.1.28"
4
4
  s.summary = "React Native Pushwoosh Push Notifications module"
5
5
  s.requires_arc = true
6
6
  s.author = 'Pushwoosh'
@@ -37,7 +37,7 @@ android {
37
37
  }
38
38
 
39
39
  ext {
40
- pushwoosh = "6.7.2"
40
+ pushwoosh = "6.7.3"
41
41
  }
42
42
 
43
43
  dependencies {
@@ -186,6 +186,42 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
186
186
  }
187
187
  }
188
188
 
189
+ @ReactMethod
190
+ public void setEmails(@NonNull ReadableArray emails, final Callback success, final Callback error) {
191
+ Pushwoosh.getInstance().setEmail(ConversionUtil.messageCodesArrayToArrayList(emails), new com.pushwoosh.function.Callback<Boolean, SetEmailException>() {
192
+ @Override
193
+ public void process(@NonNull Result<Boolean, SetEmailException> result) {
194
+ if (result.isSuccess()) {
195
+ if (success != null) {
196
+ success.invoke();
197
+ }
198
+ } else {
199
+ if (error != null) {
200
+ error.invoke(result.getException().getMessage());
201
+ }
202
+ }
203
+ }
204
+ });
205
+ }
206
+
207
+ @ReactMethod
208
+ public void setUserEmails(@NonNull String userId, @NonNull ReadableArray emails, final Callback success, final Callback error) {
209
+ Pushwoosh.getInstance().setUser(userId, ConversionUtil.messageCodesArrayToArrayList(emails), new com.pushwoosh.function.Callback<Boolean, SetUserException>() {
210
+ @Override
211
+ public void process(@NonNull Result<Boolean, SetUserException> result) {
212
+ if (result.isSuccess()) {
213
+ if (success != null) {
214
+ success.invoke();
215
+ }
216
+ } else {
217
+ if (error != null) {
218
+ error.invoke(result.getException().getMessage());
219
+ }
220
+ }
221
+ }
222
+ });
223
+ }
224
+
189
225
  @ReactMethod
190
226
  public void setTags(ReadableMap tags, final Callback success, final Callback error) {
191
227
  Pushwoosh.getInstance().sendTags(ConversionUtil.convertToTagsBundle(tags), new com.pushwoosh.function.Callback<Void, PushwooshException>() {
@@ -232,6 +268,11 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
232
268
  callback.invoke(Pushwoosh.getInstance().getHwid());
233
269
  }
234
270
 
271
+ @ReactMethod
272
+ public void getUserId(Callback callback) {
273
+ callback.invoke(Pushwoosh.getInstance().getUserId());
274
+ }
275
+
235
276
  @ReactMethod
236
277
  public void setUserId(String userId) {
237
278
  PushwooshInApp.getInstance().setUserId(userId);
@@ -166,12 +166,42 @@ RCT_EXPORT_METHOD(getHwid:(RCTResponseSenderBlock)callback) {
166
166
  }
167
167
  }
168
168
 
169
+ RCT_EXPORT_METHOD(getUserId:(RCTResponseSenderBlock)callback) {
170
+ if (callback) {
171
+ callback(@[ [[Pushwoosh sharedInstance] getUserId] ]);
172
+ }
173
+ }
174
+
169
175
  RCT_EXPORT_METHOD(getPushToken:(RCTResponseSenderBlock)callback) {
170
176
  if (callback) {
171
177
  callback(@[ objectOrNull([[PushNotificationManager pushManager] getPushToken]) ]);
172
178
  }
173
179
  }
174
180
 
181
+ RCT_EXPORT_METHOD(setEmails:(NSArray *)emails success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
182
+ [[Pushwoosh sharedInstance] setEmails:emails completion:^(NSError * _Nullable error) {
183
+ if (!error && successCallback) {
184
+ successCallback(@[]);
185
+ }
186
+
187
+ if (error && errorCallback) {
188
+ errorCallback(@[ objectOrNull([error localizedDescription]) ]);
189
+ }
190
+ }];
191
+ }
192
+
193
+ RCT_EXPORT_METHOD(setUserEmails:(NSString*)userId emails:(NSArray *)emails success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
194
+ [[Pushwoosh sharedInstance] setUser:userId emails:emails completion:^(NSError * _Nullable error) {
195
+ if (!error && successCallback) {
196
+ successCallback(@[]);
197
+ }
198
+
199
+ if (error && errorCallback) {
200
+ errorCallback(@[ objectOrNull([error localizedDescription]) ]);
201
+ }
202
+ }];
203
+ }
204
+
175
205
  RCT_EXPORT_METHOD(setTags:(NSDictionary*)tags success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
176
206
  [[PushNotificationManager pushManager] setTags:tags withCompletion:^(NSError* error) {
177
207
  if (!error && successCallback) {