pushwoosh-react-native-plugin 6.1.26 → 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.26",
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.26"
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.1"
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);
@@ -18,7 +18,7 @@
18
18
 
19
19
  #endif
20
20
 
21
- #define PUSHWOOSH_VERSION @"6.5.5"
21
+ #define PUSHWOOSH_VERSION @"6.5.7"
22
22
 
23
23
 
24
24
  @class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy;
@@ -365,6 +365,13 @@ Unregisters from push notifications.
365
365
  */
366
366
  - (NSString * _Nonnull)getHWID;
367
367
 
368
+ /**
369
+ Gets UserId.
370
+
371
+ @return userId. If the userId hasn't been set previously, then the userId is assigned the HWID.
372
+ */
373
+ - (NSString * _Nonnull)getUserId;
374
+
368
375
  /**
369
376
  Returns dictionary with enabled remove notificaton types.
370
377
 
@@ -26,6 +26,6 @@
26
26
  #import "PWInbox.h"
27
27
  #endif
28
28
 
29
- @interface PushwooshPlugin: RCTEventEmitter<RCTBridgeModule,PushNotificationDelegate>
29
+ @interface PushwooshPlugin: RCTEventEmitter<RCTBridgeModule, PushNotificationDelegate, UIApplicationDelegate>
30
30
 
31
31
  @end
@@ -71,6 +71,7 @@ RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)suc
71
71
  [PushNotificationManager initializeWithAppCode:appCode appName:nil];
72
72
  [[PushNotificationManager pushManager] sendAppOpen];
73
73
  [PushNotificationManager pushManager].delegate = self;
74
+ [[UIApplication sharedApplication] setDelegate:self];
74
75
 
75
76
  // We set Pushwoosh UNUserNotificationCenter delegate unless CUSTOM is specified in the config
76
77
  if(![notificationHandling isEqualToString:@"CUSTOM"]) {
@@ -165,12 +166,42 @@ RCT_EXPORT_METHOD(getHwid:(RCTResponseSenderBlock)callback) {
165
166
  }
166
167
  }
167
168
 
169
+ RCT_EXPORT_METHOD(getUserId:(RCTResponseSenderBlock)callback) {
170
+ if (callback) {
171
+ callback(@[ [[Pushwoosh sharedInstance] getUserId] ]);
172
+ }
173
+ }
174
+
168
175
  RCT_EXPORT_METHOD(getPushToken:(RCTResponseSenderBlock)callback) {
169
176
  if (callback) {
170
177
  callback(@[ objectOrNull([[PushNotificationManager pushManager] getPushToken]) ]);
171
178
  }
172
179
  }
173
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
+
174
205
  RCT_EXPORT_METHOD(setTags:(NSDictionary*)tags success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
175
206
  [[PushNotificationManager pushManager] setTags:tags withCompletion:^(NSError* error) {
176
207
  if (!error && successCallback) {
@@ -331,9 +362,17 @@ RCT_EXPORT_METHOD(performAction:(NSString*)code) {
331
362
  [PWInbox performActionForMessageWithCode:code];
332
363
  }
333
364
 
334
- #pragma mark - UNUserNotificationCenter Delegate Methods
365
+ #pragma mark - UIApplicationDelegate Methods
335
366
  #pragma mark -
336
367
 
368
+ - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
369
+ [[Pushwoosh sharedInstance] handlePushRegistration:deviceToken];
370
+ }
371
+
372
+ - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
373
+ [[Pushwoosh sharedInstance] handlePushRegistrationFailure:error];
374
+ }
375
+
337
376
  #pragma mark - UNUserNotificationCenter Delegate Methods
338
377
  #pragma mark -
339
378
 
Binary file