pushwoosh-react-native-plugin 6.1.15 → 6.1.17
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/index.d.ts +37 -8
- package/index.js +39 -0
- package/package.json +1 -1
- package/pushwoosh-react-native-plugin.podspec +1 -1
- package/src/android/build.gradle +3 -5
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/ConversionUtil.java +51 -0
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java +97 -0
- package/src/ios/Pushwoosh.h +104 -52
- package/src/ios/PushwooshPlugin/Pushwoosh.m +156 -64
- package/src/ios/libPushwoosh.a +0 -0
package/index.d.ts
CHANGED
|
@@ -10,11 +10,23 @@ declare module 'pushwoosh-react-native-plugin' {
|
|
|
10
10
|
userData?: Object;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
type PushwooshTags = Record<string, string | number | string[] | number[] | boolean>
|
|
14
|
+
|
|
15
|
+
type InboxNotification = {
|
|
16
|
+
code: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
imageUrl?: string;
|
|
20
|
+
sendDate?: string;
|
|
21
|
+
type?: number;
|
|
22
|
+
bannerUrl?: string;
|
|
23
|
+
customData?: Object;
|
|
24
|
+
isRead?: boolean;
|
|
25
|
+
isActionPerformed?: boolean;
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
interface Pushwoosh {
|
|
29
|
+
//general interaction with Pushwoosh
|
|
18
30
|
init(config: PushwooshConfig, success?: () => void, fail?: () => void): void;
|
|
19
31
|
createLocalNotification(notification: LocalNotification): void;
|
|
20
32
|
clearLocalNotification(): void;
|
|
@@ -23,7 +35,7 @@ declare module 'pushwoosh-react-native-plugin' {
|
|
|
23
35
|
unregister(success?: (token: string) => void, fail?: (error: Error) => void): void;
|
|
24
36
|
onPushOpen(callback: () => void, fail?: ()=> void): void;
|
|
25
37
|
setTags(
|
|
26
|
-
tags:
|
|
38
|
+
tags: PushwooshTags,
|
|
27
39
|
success?: () => void,
|
|
28
40
|
fail?: (error: Error) => void
|
|
29
41
|
): void;
|
|
@@ -34,16 +46,36 @@ declare module 'pushwoosh-react-native-plugin' {
|
|
|
34
46
|
getHwid(success: (hwid: string) => void): void;
|
|
35
47
|
setUserId(userId: string, success?: ()=> void, fail?: (error: Error) => void): void;
|
|
36
48
|
postEvent(event: string, attributes?: Record<string, string>): void;
|
|
49
|
+
enableHuaweiPushNotifications(): void;
|
|
50
|
+
|
|
51
|
+
//badge methods
|
|
37
52
|
setApplicationIconBadgeNumber(badgeNumber: number): void;
|
|
38
53
|
getApplicationIconBadgeNumber(callback: (badge: number) => void): void;
|
|
39
54
|
addToApplicationIconBadgeNumber(badgeNumber: number): void;
|
|
55
|
+
|
|
56
|
+
//Notification appearance
|
|
40
57
|
setMultiNotificationMode(on: boolean): void;
|
|
41
58
|
setLightScreenOnNotification(on: boolean): void;
|
|
42
59
|
setEnableLED(on: boolean): void;
|
|
43
60
|
setColorLED(color: number): void;
|
|
44
61
|
setSoundType(type: number): void;
|
|
45
62
|
setVibrateType(type: number): void;
|
|
63
|
+
setNotificationIconBackgroundColor(color: string): void;
|
|
64
|
+
setLanguage(language: string): void;
|
|
65
|
+
|
|
66
|
+
//Inbox API
|
|
46
67
|
presentInboxUI(style?: Object): void;
|
|
68
|
+
messagesWithNoActionPerformedCount(callback: (result: number) => void): void;
|
|
69
|
+
unreadMessagesCount(callback: (result: number) => void): void;
|
|
70
|
+
messagesCount(callback: (result: number) => void): void;
|
|
71
|
+
loadMessages(success: (notifications: InboxNotification[]) => void, fail?: (error: Error) => void): void;
|
|
72
|
+
readMessage(id: string): void;
|
|
73
|
+
readMessages(ids: string[]): void;
|
|
74
|
+
deleteMessage(id: string): void;
|
|
75
|
+
deleteMessages(ids: string[]): void;
|
|
76
|
+
performAction(id: string): void;
|
|
77
|
+
|
|
78
|
+
//GDPR methods
|
|
47
79
|
showGDPRConsentUI(): void;
|
|
48
80
|
showGDPRDeletionUI(): void;
|
|
49
81
|
isDeviceDataRemoved(success: (isRemoved: boolean) => void): void;
|
|
@@ -51,11 +83,8 @@ declare module 'pushwoosh-react-native-plugin' {
|
|
|
51
83
|
isAvailableGDPR(success: (isAvailable: boolean) => void): void;
|
|
52
84
|
setCommunicationEnabled(enabled: boolean, success?: () => void, fail?: (error: Error) => void): void;
|
|
53
85
|
removeAllDeviceData(success?: () => void, fail?: (error: Error) => void): void;
|
|
54
|
-
setNotificationIconBackgroundColor(color: string): void;
|
|
55
|
-
setLanguage(language: string): void;
|
|
56
|
-
enableHuaweiPushNotifications(): void;
|
|
57
86
|
}
|
|
58
87
|
|
|
59
|
-
|
|
88
|
+
const Pushwoosh: Pushwoosh;
|
|
60
89
|
export = Pushwoosh;
|
|
61
|
-
}
|
|
90
|
+
}
|
package/index.js
CHANGED
|
@@ -459,6 +459,45 @@ class PushNotification {
|
|
|
459
459
|
PushwooshModule.presentInboxUI(style);
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
+
messagesWithNoActionPerformedCount(result: Function) {
|
|
463
|
+
PushwooshModule.messagesWithNoActionPerformedCount(result);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
unreadMessagesCount(result: Function) {
|
|
467
|
+
PushwooshModule.unreadMessagesCount(result);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
messagesCount(result: Function) {
|
|
471
|
+
PushwooshModule.messagesCount(result);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
loadMessages(success: Function, fail: ?Function) {
|
|
475
|
+
if (!fail) {
|
|
476
|
+
fail = function() {};
|
|
477
|
+
}
|
|
478
|
+
PushwooshModule.loadMessages(success, fail);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
readMessage(id: string) {
|
|
482
|
+
PushwooshModule.readMessage(id);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
readMessages(ids: Array) {
|
|
486
|
+
PushwooshModule.readMessages(ids);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
deleteMessage(id: string) {
|
|
490
|
+
PushwooshModule.deleteMessage(id);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
deleteMessages(ids: Array) {
|
|
494
|
+
PushwooshModule.deleteMessages(ids);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
performAction(id: string) {
|
|
498
|
+
PushwooshModule.performAction(id);
|
|
499
|
+
}
|
|
500
|
+
|
|
462
501
|
// Show inApp for change setting Enable/disable all communication with Pushwoosh
|
|
463
502
|
showGDPRConsentUI(){
|
|
464
503
|
PushwooshModule.showGDPRConsentUI();
|
package/package.json
CHANGED
package/src/android/build.gradle
CHANGED
|
@@ -23,10 +23,10 @@ allprojects {
|
|
|
23
23
|
apply plugin: 'com.android.library'
|
|
24
24
|
|
|
25
25
|
android {
|
|
26
|
-
compileSdkVersion
|
|
26
|
+
compileSdkVersion 31
|
|
27
27
|
defaultConfig {
|
|
28
28
|
minSdkVersion 17
|
|
29
|
-
targetSdkVersion
|
|
29
|
+
targetSdkVersion 31
|
|
30
30
|
}
|
|
31
31
|
buildTypes {
|
|
32
32
|
release {
|
|
@@ -37,11 +37,9 @@ android {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
ext {
|
|
40
|
-
pushwoosh = "6.6.
|
|
40
|
+
pushwoosh = "6.6.5"
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
evaluationDependsOn(':app')
|
|
44
|
-
|
|
45
43
|
dependencies {
|
|
46
44
|
implementation 'com.facebook.react:react-native:+'
|
|
47
45
|
implementation "com.pushwoosh:pushwoosh:${pushwoosh}"
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
package com.pushwoosh.reactnativeplugin;
|
|
2
2
|
|
|
3
|
+
import android.os.Bundle;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import java.util.ArrayList;
|
|
3
7
|
import java.util.Iterator;
|
|
4
8
|
|
|
5
9
|
import com.facebook.react.bridge.ReadableArray;
|
|
@@ -10,6 +14,8 @@ import com.facebook.react.bridge.WritableArray;
|
|
|
10
14
|
import com.facebook.react.bridge.WritableMap;
|
|
11
15
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
12
16
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
17
|
+
import com.pushwoosh.inbox.data.InboxMessage;
|
|
18
|
+
import com.pushwoosh.internal.utils.JsonUtils;
|
|
13
19
|
import com.pushwoosh.internal.utils.PWLog;
|
|
14
20
|
import com.pushwoosh.tags.TagsBundle;
|
|
15
21
|
|
|
@@ -178,4 +184,49 @@ public final class ConversionUtil {
|
|
|
178
184
|
|
|
179
185
|
return result;
|
|
180
186
|
}
|
|
187
|
+
|
|
188
|
+
public static WritableMap inboxMessageToWritableMap(InboxMessage message) {
|
|
189
|
+
return toWritableMap(inboxMessageToJson(message));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
public static JSONObject inboxMessageToJson(InboxMessage message) {
|
|
193
|
+
JSONObject object = new JSONObject();
|
|
194
|
+
try {
|
|
195
|
+
object.put("code", message.getCode())
|
|
196
|
+
.put("title", message.getTitle())
|
|
197
|
+
.put("imageUrl", message.getImageUrl())
|
|
198
|
+
.put("message",message.getMessage())
|
|
199
|
+
.put("sendDate",message.getSendDate().toString())
|
|
200
|
+
.put("type", message.getType().getCode())
|
|
201
|
+
.put("bannerUrl", message.getBannerUrl())
|
|
202
|
+
.put("isRead",message.isRead())
|
|
203
|
+
.put("isActionPerformed",message.isActionPerformed());
|
|
204
|
+
|
|
205
|
+
Bundle bundle = JsonUtils.jsonStringToBundle( message.getActionParams());
|
|
206
|
+
String customData = bundle.getString("u");
|
|
207
|
+
if (customData != null) {
|
|
208
|
+
object.put("customData", customData);
|
|
209
|
+
}
|
|
210
|
+
} catch (JSONException e) {
|
|
211
|
+
Log.e("PushwooshInbox", "Failed to fetch inbox message :" + e.getMessage());
|
|
212
|
+
}
|
|
213
|
+
return object;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public static ArrayList<String> messageCodesArrayToArrayList(ReadableArray readableArray) {
|
|
217
|
+
ArrayList<String> result = new ArrayList<>();
|
|
218
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
219
|
+
ReadableType indexType = readableArray.getType(i);
|
|
220
|
+
try {
|
|
221
|
+
if (indexType == ReadableType.String) {
|
|
222
|
+
result.add(readableArray.getString(i));
|
|
223
|
+
} else {
|
|
224
|
+
PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".");
|
|
225
|
+
}
|
|
226
|
+
} catch (Exception e) {
|
|
227
|
+
PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".", e);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
181
232
|
}
|
|
@@ -7,12 +7,17 @@ import android.content.Intent;
|
|
|
7
7
|
import android.graphics.Color;
|
|
8
8
|
import android.text.TextUtils;
|
|
9
9
|
|
|
10
|
+
import androidx.annotation.NonNull;
|
|
11
|
+
import androidx.annotation.Nullable;
|
|
12
|
+
|
|
10
13
|
import com.facebook.react.bridge.Callback;
|
|
11
14
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
12
15
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
13
16
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
14
17
|
import com.facebook.react.bridge.ReactMethod;
|
|
18
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
15
19
|
import com.facebook.react.bridge.ReadableMap;
|
|
20
|
+
import com.facebook.react.bridge.WritableNativeArray;
|
|
16
21
|
import com.pushwoosh.GDPRManager;
|
|
17
22
|
import com.pushwoosh.Pushwoosh;
|
|
18
23
|
import com.pushwoosh.RegisterForPushNotificationsResultData;
|
|
@@ -24,6 +29,9 @@ import com.pushwoosh.exception.RegisterForPushNotificationsException;
|
|
|
24
29
|
import com.pushwoosh.exception.UnregisterForPushNotificationException;
|
|
25
30
|
import com.pushwoosh.function.Result;
|
|
26
31
|
import com.pushwoosh.inapp.PushwooshInApp;
|
|
32
|
+
import com.pushwoosh.inbox.PushwooshInbox;
|
|
33
|
+
import com.pushwoosh.inbox.data.InboxMessage;
|
|
34
|
+
import com.pushwoosh.inbox.exception.InboxMessagesException;
|
|
27
35
|
import com.pushwoosh.inbox.ui.presentation.view.activity.InboxActivity;
|
|
28
36
|
import com.pushwoosh.internal.network.NetworkModule;
|
|
29
37
|
import com.pushwoosh.internal.platform.AndroidPlatformModule;
|
|
@@ -37,6 +45,9 @@ import com.pushwoosh.notification.LocalNotificationReceiver;
|
|
|
37
45
|
|
|
38
46
|
import org.json.JSONObject;
|
|
39
47
|
|
|
48
|
+
import java.util.ArrayList;
|
|
49
|
+
import java.util.Collection;
|
|
50
|
+
|
|
40
51
|
public class PushwooshPlugin extends ReactContextBaseJavaModule implements LifecycleEventListener {
|
|
41
52
|
|
|
42
53
|
static final String TAG = "ReactNativePlugin";
|
|
@@ -352,6 +363,92 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
|
|
|
352
363
|
}
|
|
353
364
|
}
|
|
354
365
|
|
|
366
|
+
@ReactMethod
|
|
367
|
+
public void messagesWithNoActionPerformedCount(final Callback callback) {
|
|
368
|
+
PushwooshInbox.messagesWithNoActionPerformedCount(new com.pushwoosh.function.Callback<Integer, InboxMessagesException>() {
|
|
369
|
+
@Override
|
|
370
|
+
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
371
|
+
if (result.isSuccess() && callback != null) {
|
|
372
|
+
callback.invoke(result.getData());
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
@ReactMethod
|
|
379
|
+
public void unreadMessagesCount(final Callback callback) {
|
|
380
|
+
PushwooshInbox.unreadMessagesCount(new com.pushwoosh.function.Callback<Integer, InboxMessagesException>() {
|
|
381
|
+
@Override
|
|
382
|
+
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
383
|
+
if (result.isSuccess() && callback != null) {
|
|
384
|
+
callback.invoke(result.getData());
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
@ReactMethod
|
|
391
|
+
public void messagesCount(final Callback callback) {
|
|
392
|
+
PushwooshInbox.messagesCount(new com.pushwoosh.function.Callback<Integer, InboxMessagesException>() {
|
|
393
|
+
@Override
|
|
394
|
+
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
395
|
+
if (result.isSuccess() && callback != null) {
|
|
396
|
+
callback.invoke(result.getData());
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
@ReactMethod
|
|
403
|
+
public void loadMessages(@NonNull final Callback success, @Nullable final Callback error) {
|
|
404
|
+
PushwooshInbox.loadMessages(new com.pushwoosh.function.Callback<Collection<InboxMessage>, InboxMessagesException>() {
|
|
405
|
+
@Override
|
|
406
|
+
public void process(@NonNull Result<Collection<InboxMessage>, InboxMessagesException> result) {
|
|
407
|
+
try {
|
|
408
|
+
if (result.isSuccess() && result.getData() != null) {
|
|
409
|
+
ArrayList<InboxMessage> messagesList = new ArrayList<>(result.getData());
|
|
410
|
+
WritableNativeArray writableArray = new WritableNativeArray();
|
|
411
|
+
for (InboxMessage message : messagesList) {
|
|
412
|
+
writableArray.pushMap(ConversionUtil.inboxMessageToWritableMap(message));
|
|
413
|
+
}
|
|
414
|
+
success.invoke(writableArray);
|
|
415
|
+
} else if (error != null) {
|
|
416
|
+
error.invoke(TAG + "Failed to fetch inbox messages from server");
|
|
417
|
+
}
|
|
418
|
+
} catch (Exception e) {
|
|
419
|
+
if (error != null) {
|
|
420
|
+
error.invoke(e.getLocalizedMessage());
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
@ReactMethod
|
|
428
|
+
public void readMessage(String id) {
|
|
429
|
+
PushwooshInbox.readMessage(id);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
@ReactMethod
|
|
433
|
+
public void readMessages(ReadableArray codes) {
|
|
434
|
+
PushwooshInbox.readMessages(ConversionUtil.messageCodesArrayToArrayList(codes));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
@ReactMethod
|
|
438
|
+
public void deleteMessage(String id) {
|
|
439
|
+
PushwooshInbox.deleteMessage(id);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
@ReactMethod
|
|
443
|
+
public void deleteMessages(ReadableArray codes) {
|
|
444
|
+
PushwooshInbox.deleteMessages(ConversionUtil.messageCodesArrayToArrayList(codes));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
@ReactMethod
|
|
448
|
+
public void performAction(String id) {
|
|
449
|
+
PushwooshInbox.performAction(id);
|
|
450
|
+
}
|
|
451
|
+
|
|
355
452
|
@ReactMethod
|
|
356
453
|
public void showGDPRConsentUI(){
|
|
357
454
|
GDPRManager.getInstance().showGDPRConsentUI();
|
package/src/ios/Pushwoosh.h
CHANGED
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
#endif
|
|
20
20
|
|
|
21
|
-
#define PUSHWOOSH_VERSION @"6.4.
|
|
21
|
+
#define PUSHWOOSH_VERSION @"6.4.8"
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy;
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
typedef void (^PushwooshRegistrationHandler)(NSString *token, NSError *error);
|
|
28
|
-
typedef void (^PushwooshGetTagsHandler)(NSDictionary *tags);
|
|
29
|
-
typedef void (^PushwooshErrorHandler)(NSError *error);
|
|
27
|
+
typedef void (^PushwooshRegistrationHandler)(NSString * _Nullable token, NSError * _Nullable error);
|
|
28
|
+
typedef void (^PushwooshGetTagsHandler)(NSDictionary * _Nullable tags);
|
|
29
|
+
typedef void (^PushwooshErrorHandler)(NSError * _Nullable error);
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -43,7 +43,7 @@ typedef void (^PushwooshErrorHandler)(NSError *error);
|
|
|
43
43
|
@param pushwoosh The push manager that received the remote notification.
|
|
44
44
|
@param message A PWMessage object that contains information referring to the remote notification, potentially including a badge number for the application icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data.
|
|
45
45
|
*/
|
|
46
|
-
- (void)pushwoosh:(Pushwoosh *)pushwoosh onMessageReceived:(PWMessage *)message;
|
|
46
|
+
- (void)pushwoosh:(Pushwoosh * _Nonnull)pushwoosh onMessageReceived:(PWMessage * _Nonnull)message;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
Tells the delegate that the user has pressed on the push notification banner.
|
|
@@ -51,7 +51,54 @@ Tells the delegate that the user has pressed on the push notification banner.
|
|
|
51
51
|
@param pushwoosh The push manager that received the remote notification.
|
|
52
52
|
@param message A PWMessage object that contains information about the remote notification, potentially including a badge number for the application icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data.
|
|
53
53
|
*/
|
|
54
|
-
- (void)pushwoosh:(Pushwoosh *)pushwoosh onMessageOpened:(PWMessage *)message;
|
|
54
|
+
- (void)pushwoosh:(Pushwoosh * _Nonnull)pushwoosh onMessageOpened:(PWMessage * _Nonnull)message;
|
|
55
|
+
|
|
56
|
+
@end
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
`PWPurchaseDelegate` protocol defines the methods that can be implemented in the delegate of the `Pushwoosh` class' singleton object.
|
|
60
|
+
These methods provide callbacks for events related to purchasing In-App products from rich medias, such as successful purchase event, failed payment, etc.
|
|
61
|
+
These methods implementation allows to react on such events properly.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
@protocol PWPurchaseDelegate <NSObject>
|
|
65
|
+
|
|
66
|
+
@optional
|
|
67
|
+
/**
|
|
68
|
+
Tells the delegate that the application received the array of products
|
|
69
|
+
|
|
70
|
+
@param products Array of SKProduct instances.
|
|
71
|
+
*/
|
|
72
|
+
- (void)onPWInAppPurchaseHelperProducts:(NSArray<SKProduct *>* _Nullable)products;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
Tells the delegate that the transaction is in queue, user has been charged.
|
|
76
|
+
|
|
77
|
+
@param identifier Identifier agreed upon with the store.
|
|
78
|
+
*/
|
|
79
|
+
- (void)onPWInAppPurchaseHelperPaymentComplete:(NSString* _Nullable)identifier;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
Tells the delegate that the transaction was cancelled or failed before being added to the server queue.
|
|
83
|
+
|
|
84
|
+
@param identifier The unique server-provided identifier.
|
|
85
|
+
@param error The transaction failed.
|
|
86
|
+
*/
|
|
87
|
+
- (void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
Tells the delegate that a user initiates an IAP buy from the App Store
|
|
91
|
+
|
|
92
|
+
@param identifier Product identifier
|
|
93
|
+
*/
|
|
94
|
+
- (void)onPWInAppPurchaseHelperCallPromotedPurchase:(NSString* _Nullable)identifier;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
Tells the delegate that an error occurred while restoring transactions.
|
|
98
|
+
|
|
99
|
+
@param error Error transaction.
|
|
100
|
+
*/
|
|
101
|
+
- (void)onPWInAppPurchaseHelperRestoreCompletedTransactionsFailed:(NSError * _Nullable)error;
|
|
55
102
|
|
|
56
103
|
@end
|
|
57
104
|
|
|
@@ -64,17 +111,17 @@ Tells the delegate that the user has pressed on the push notification banner.
|
|
|
64
111
|
/**
|
|
65
112
|
Title of the push message.
|
|
66
113
|
*/
|
|
67
|
-
@property (nonatomic, readonly) NSString *title;
|
|
114
|
+
@property (nonatomic, readonly) NSString * _Nullable title;
|
|
68
115
|
|
|
69
116
|
/**
|
|
70
117
|
Subtitle of the push message.
|
|
71
118
|
*/
|
|
72
|
-
@property (nonatomic, readonly) NSString *subTitle;
|
|
119
|
+
@property (nonatomic, readonly) NSString * _Nullable subTitle;
|
|
73
120
|
|
|
74
121
|
/**
|
|
75
122
|
Body of the push message.
|
|
76
123
|
*/
|
|
77
|
-
@property (nonatomic, readonly) NSString *message;
|
|
124
|
+
@property (nonatomic, readonly) NSString * _Nullable message;
|
|
78
125
|
|
|
79
126
|
/**
|
|
80
127
|
Badge number of the push message.
|
|
@@ -89,7 +136,7 @@ Tells the delegate that the user has pressed on the push notification banner.
|
|
|
89
136
|
/**
|
|
90
137
|
Remote URL or deeplink from the push message.
|
|
91
138
|
*/
|
|
92
|
-
@property (nonatomic, readonly) NSString *link;
|
|
139
|
+
@property (nonatomic, readonly) NSString * _Nullable link;
|
|
93
140
|
|
|
94
141
|
/**
|
|
95
142
|
Returns YES if this message received/opened then the app is in foreground state.
|
|
@@ -109,17 +156,17 @@ Tells the delegate that the user has pressed on the push notification banner.
|
|
|
109
156
|
/**
|
|
110
157
|
Gets custom JSON data from push notifications dictionary as specified in Pushwoosh Control Panel.
|
|
111
158
|
*/
|
|
112
|
-
@property (nonatomic, readonly) NSDictionary *customData;
|
|
159
|
+
@property (nonatomic, readonly) NSDictionary * _Nullable customData;
|
|
113
160
|
|
|
114
161
|
/**
|
|
115
162
|
Original payload of the message.
|
|
116
163
|
*/
|
|
117
|
-
@property (nonatomic, readonly) NSDictionary *payload;
|
|
164
|
+
@property (nonatomic, readonly) NSDictionary * _Nullable payload;
|
|
118
165
|
|
|
119
166
|
/**
|
|
120
167
|
Returns YES if this message is recieved from Pushwoosh.
|
|
121
168
|
*/
|
|
122
|
-
+ (BOOL)isPushwooshMessage:(NSDictionary *)userInfo;
|
|
169
|
+
+ (BOOL)isPushwooshMessage:(NSDictionary *_Nonnull)userInfo;
|
|
123
170
|
|
|
124
171
|
@end
|
|
125
172
|
|
|
@@ -132,13 +179,18 @@ Tells the delegate that the user has pressed on the push notification banner.
|
|
|
132
179
|
/**
|
|
133
180
|
Pushwoosh Application ID. Usually retrieved automatically from Info.plist parameter `Pushwoosh_APPID`
|
|
134
181
|
*/
|
|
135
|
-
@property (nonatomic, copy, readonly) NSString *applicationCode;
|
|
182
|
+
@property (nonatomic, copy, readonly) NSString * _Nonnull applicationCode;
|
|
136
183
|
|
|
137
184
|
/**
|
|
138
185
|
`PushNotificationDelegate` protocol delegate that would receive the information about events for push notification manager such as registering with APS services, receiving push notifications or working with the received notification.
|
|
139
186
|
Pushwoosh Runtime sets it to ApplicationDelegate by default
|
|
140
187
|
*/
|
|
141
|
-
@property (nonatomic, weak) NSObject<PWMessagingDelegate> *delegate;
|
|
188
|
+
@property (nonatomic, weak) NSObject<PWMessagingDelegate> * _Nullable delegate;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
`PushPurchaseDelegate` protocol delegate that would receive the information about events related to purchasing InApp products from rich medias
|
|
192
|
+
*/
|
|
193
|
+
@property (nonatomic, weak) NSObject<PWPurchaseDelegate> * _Nullable purchaseDelegate;
|
|
142
194
|
|
|
143
195
|
#if TARGET_OS_IOS || TARGET_OS_WATCH
|
|
144
196
|
|
|
@@ -157,62 +209,62 @@ Tells the delegate that the user has pressed on the push notification banner.
|
|
|
157
209
|
/**
|
|
158
210
|
Returns push notification payload if the app was started in response to push notification or null otherwise
|
|
159
211
|
*/
|
|
160
|
-
@property (nonatomic, copy, readonly) NSDictionary *launchNotification;
|
|
212
|
+
@property (nonatomic, copy, readonly) NSDictionary * _Nullable launchNotification;
|
|
161
213
|
|
|
162
214
|
/**
|
|
163
215
|
Proxy contains UNUserNotificationCenterDelegate objects.
|
|
164
216
|
*/
|
|
165
|
-
@property (nonatomic, readonly) PWNotificationCenterDelegateProxy *notificationCenterDelegateProxy;
|
|
217
|
+
@property (nonatomic, readonly) PWNotificationCenterDelegateProxy * _Nullable notificationCenterDelegateProxy;
|
|
166
218
|
|
|
167
219
|
/**
|
|
168
220
|
Set custom application language. Must be a lowercase two-letter code according to ISO-639-1 standard ("en", "de", "fr", etc.).
|
|
169
221
|
Device language used by default.
|
|
170
222
|
Set to nil if you want to use device language again.
|
|
171
223
|
*/
|
|
172
|
-
@property (nonatomic) NSString *language;
|
|
224
|
+
@property (nonatomic) NSString * _Nonnull language;
|
|
173
225
|
|
|
174
226
|
/**
|
|
175
227
|
Initializes Pushwoosh.
|
|
176
228
|
@param appCode Pushwoosh App ID.
|
|
177
229
|
*/
|
|
178
|
-
+ (void)initializeWithAppCode:(NSString *)appCode;
|
|
230
|
+
+ (void)initializeWithAppCode:(NSString *_Nonnull)appCode;
|
|
179
231
|
|
|
180
232
|
/**
|
|
181
233
|
Returns an object representing the current push manager.
|
|
182
234
|
|
|
183
235
|
@return A singleton object that represents the push manager.
|
|
184
236
|
*/
|
|
185
|
-
+ (instancetype)sharedInstance;
|
|
237
|
+
+ (instancetype _Nonnull )sharedInstance;
|
|
186
238
|
|
|
187
239
|
/**
|
|
188
240
|
Registers for push notifications. By default registeres for "UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert" flags.
|
|
189
241
|
Automatically detects if you have "newsstand-content" in "UIBackgroundModes" and adds "UIRemoteNotificationTypeNewsstandContentAvailability" flag.
|
|
190
242
|
*/
|
|
191
243
|
- (void)registerForPushNotifications;
|
|
192
|
-
- (void)registerForPushNotificationsWithCompletion:(PushwooshRegistrationHandler)completion;
|
|
244
|
+
- (void)registerForPushNotificationsWithCompletion:(PushwooshRegistrationHandler _Nullable )completion;
|
|
193
245
|
|
|
194
246
|
/**
|
|
195
247
|
Unregisters from push notifications.
|
|
196
248
|
*/
|
|
197
249
|
- (void)unregisterForPushNotifications;
|
|
198
|
-
- (void)unregisterForPushNotificationsWithCompletion:(void (^)(NSError *error))completion;
|
|
250
|
+
- (void)unregisterForPushNotificationsWithCompletion:(void (^_Nullable)(NSError * _Nullable error))completion;
|
|
199
251
|
|
|
200
252
|
/**
|
|
201
253
|
Handle registration to remote notifications.
|
|
202
254
|
*/
|
|
203
|
-
- (void)handlePushRegistration:(NSData *)devToken;
|
|
204
|
-
- (void)handlePushRegistrationFailure:(NSError *)error;
|
|
255
|
+
- (void)handlePushRegistration:(NSData * _Nonnull)devToken;
|
|
256
|
+
- (void)handlePushRegistrationFailure:(NSError * _Nonnull)error;
|
|
205
257
|
|
|
206
258
|
/**
|
|
207
259
|
Handle received push notification.
|
|
208
260
|
*/
|
|
209
|
-
- (BOOL)handlePushReceived:(NSDictionary *)userInfo;
|
|
261
|
+
- (BOOL)handlePushReceived:(NSDictionary * _Nonnull)userInfo;
|
|
210
262
|
|
|
211
263
|
/**
|
|
212
264
|
* Change default base url to reverse proxy url
|
|
213
265
|
* @param url - reverse proxy url
|
|
214
266
|
*/
|
|
215
|
-
- (void)setReverseProxy:(NSString *)url;
|
|
267
|
+
- (void)setReverseProxy:(NSString * _Nonnull)url;
|
|
216
268
|
|
|
217
269
|
/**
|
|
218
270
|
* Disables reverse proxy
|
|
@@ -235,16 +287,16 @@ Unregisters from push notifications.
|
|
|
235
287
|
|
|
236
288
|
@param tags Dictionary representation of tags to send.
|
|
237
289
|
*/
|
|
238
|
-
- (void)setTags:(NSDictionary *)tags;
|
|
290
|
+
- (void)setTags:(NSDictionary * _Nonnull)tags;
|
|
239
291
|
|
|
240
292
|
/**
|
|
241
293
|
Send tags to server with completion block. If setTags succeeds competion is called with nil argument. If setTags fails completion is called with error.
|
|
242
294
|
*/
|
|
243
|
-
- (void)setTags:(NSDictionary *)tags completion:(void (^)(NSError *error))completion;
|
|
295
|
+
- (void)setTags:(NSDictionary * _Nonnull)tags completion:(void (^_Nullable)(NSError * _Nullable error))completion;
|
|
244
296
|
|
|
245
|
-
- (void)setEmailTags:(NSDictionary *)tags forEmail:(NSString *)email;
|
|
297
|
+
- (void)setEmailTags:(NSDictionary * _Nonnull)tags forEmail:(NSString * _Nonnull)email;
|
|
246
298
|
|
|
247
|
-
- (void)setEmailTags:(NSDictionary *)tags forEmail:(NSString *)email completion:(void(^)(NSError *error))completion;
|
|
299
|
+
- (void)setEmailTags:(NSDictionary * _Nonnull)tags forEmail:(NSString * _Nonnull)email completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
|
|
248
300
|
|
|
249
301
|
/**
|
|
250
302
|
Get tags from server. Calls delegate method if exists and handler (block).
|
|
@@ -257,7 +309,7 @@ Unregisters from push notifications.
|
|
|
257
309
|
}
|
|
258
310
|
@param errorHandler The block is executed on the unsuccessful completion of the request. This block has no return value and takes one argument: the error that occurred during the request.
|
|
259
311
|
*/
|
|
260
|
-
- (void)getTags:(PushwooshGetTagsHandler)successHandler onFailure:(PushwooshErrorHandler)errorHandler;
|
|
312
|
+
- (void)getTags:(PushwooshGetTagsHandler _Nullable)successHandler onFailure:(PushwooshErrorHandler _Nullable)errorHandler;
|
|
261
313
|
|
|
262
314
|
/**
|
|
263
315
|
Sends current badge value to server. Called internally by SDK Runtime when `UIApplication` `setApplicationBadgeNumber:` is set. This function is used for "auto-incremeting" badges to work.
|
|
@@ -270,7 +322,7 @@ Unregisters from push notifications.
|
|
|
270
322
|
/**
|
|
271
323
|
Pushwoosh SDK version.
|
|
272
324
|
*/
|
|
273
|
-
+ (NSString *)version;
|
|
325
|
+
+ (NSString * _Nonnull)version;
|
|
274
326
|
|
|
275
327
|
#if TARGET_OS_IOS
|
|
276
328
|
/**
|
|
@@ -285,7 +337,7 @@ Unregisters from push notifications.
|
|
|
285
337
|
|
|
286
338
|
@param transactions Array of SKPaymentTransaction items as received in the payment queue.
|
|
287
339
|
*/
|
|
288
|
-
- (void)sendSKPaymentTransactions:(NSArray *)transactions;
|
|
340
|
+
- (void)sendSKPaymentTransactions:(NSArray * _Nonnull)transactions;
|
|
289
341
|
|
|
290
342
|
/**
|
|
291
343
|
Tracks individual in-app purchase. See recommended `sendSKPaymentTransactions:` method.
|
|
@@ -295,7 +347,7 @@ Unregisters from push notifications.
|
|
|
295
347
|
@param currencyCode currency of the price (ex: @"USD")
|
|
296
348
|
@param date time of the purchase (ex: [NSDate now])
|
|
297
349
|
*/
|
|
298
|
-
- (void)sendPurchase:(NSString *)productIdentifier withPrice:(NSDecimalNumber *)price currencyCode:(NSString *)currencyCode andDate:(NSDate *)date;
|
|
350
|
+
- (void)sendPurchase:(NSString * _Nonnull)productIdentifier withPrice:(NSDecimalNumber * _Nonnull)price currencyCode:(NSString * _Nonnull)currencyCode andDate:(NSDate * _Nonnull)date;
|
|
299
351
|
|
|
300
352
|
#endif
|
|
301
353
|
/**
|
|
@@ -303,7 +355,7 @@ Unregisters from push notifications.
|
|
|
303
355
|
|
|
304
356
|
@return Current push token. May be nil if no push token is available yet.
|
|
305
357
|
*/
|
|
306
|
-
- (NSString *)getPushToken;
|
|
358
|
+
- (NSString * _Nullable)getPushToken;
|
|
307
359
|
|
|
308
360
|
/**
|
|
309
361
|
Gets HWID. Unique device identifier that used in all API calls with Pushwoosh.
|
|
@@ -311,7 +363,7 @@ Unregisters from push notifications.
|
|
|
311
363
|
|
|
312
364
|
@return Unique device identifier.
|
|
313
365
|
*/
|
|
314
|
-
- (NSString *)getHWID;
|
|
366
|
+
- (NSString * _Nonnull)getHWID;
|
|
315
367
|
|
|
316
368
|
/**
|
|
317
369
|
Returns dictionary with enabled remove notificaton types.
|
|
@@ -341,7 +393,7 @@ Unregisters from push notifications.
|
|
|
341
393
|
|
|
342
394
|
Note: In the latter example "enabled" field means that device can receive push notification but could not display alerts (ex: silent push)
|
|
343
395
|
*/
|
|
344
|
-
+ (NSMutableDictionary *)getRemoteNotificationStatus;
|
|
396
|
+
+ (NSMutableDictionary * _Nullable)getRemoteNotificationStatus;
|
|
345
397
|
|
|
346
398
|
/**
|
|
347
399
|
Clears the notifications from the notification center.
|
|
@@ -355,7 +407,7 @@ Unregisters from push notifications.
|
|
|
355
407
|
|
|
356
408
|
@param userId user identifier
|
|
357
409
|
*/
|
|
358
|
-
- (void)setUserId:(NSString *)userId completion:(void(^)(NSError * error))completion;
|
|
410
|
+
- (void)setUserId:(NSString * _Nonnull)userId completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
|
|
359
411
|
|
|
360
412
|
/**
|
|
361
413
|
Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
|
|
@@ -363,7 +415,7 @@ Unregisters from push notifications.
|
|
|
363
415
|
|
|
364
416
|
@param userId user identifier
|
|
365
417
|
*/
|
|
366
|
-
- (void)setUserId:(NSString *)userId;
|
|
418
|
+
- (void)setUserId:(NSString * _Nonnull)userId;
|
|
367
419
|
|
|
368
420
|
/**
|
|
369
421
|
Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
|
|
@@ -373,7 +425,7 @@ Unregisters from push notifications.
|
|
|
373
425
|
@param userId user identifier
|
|
374
426
|
@param emails user's emails array
|
|
375
427
|
*/
|
|
376
|
-
- (void)setUser:(NSString *)userId emails:(NSArray *)emails completion:(void(^)(NSError * error))completion;
|
|
428
|
+
- (void)setUser:(NSString * _Nonnull)userId emails:(NSArray * _Nonnull)emails completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
|
|
377
429
|
|
|
378
430
|
|
|
379
431
|
/**
|
|
@@ -383,7 +435,7 @@ Unregisters from push notifications.
|
|
|
383
435
|
@param userId user identifier
|
|
384
436
|
@param emails user's emails array
|
|
385
437
|
*/
|
|
386
|
-
- (void)setUser:(NSString *)userId emails:(NSArray *)emails;
|
|
438
|
+
- (void)setUser:(NSString * _Nonnull)userId emails:(NSArray * _Nonnull)emails;
|
|
387
439
|
|
|
388
440
|
/**
|
|
389
441
|
Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
|
|
@@ -393,7 +445,7 @@ Unregisters from push notifications.
|
|
|
393
445
|
@param userId user identifier
|
|
394
446
|
@param email user's email string
|
|
395
447
|
*/
|
|
396
|
-
- (void)setUser:(NSString *)userId email:(NSString *)email completion:(void(^)(NSError * error))completion;
|
|
448
|
+
- (void)setUser:(NSString * _Nonnull)userId email:(NSString * _Nonnull)email completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
|
|
397
449
|
|
|
398
450
|
/**
|
|
399
451
|
Register emails list associated to the current user.
|
|
@@ -401,14 +453,14 @@ Unregisters from push notifications.
|
|
|
401
453
|
|
|
402
454
|
@param emails user's emails array
|
|
403
455
|
*/
|
|
404
|
-
- (void)setEmails:(NSArray *)emails completion:(void(^)(NSError * error))completion;
|
|
456
|
+
- (void)setEmails:(NSArray * _Nonnull)emails completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
|
|
405
457
|
|
|
406
458
|
/**
|
|
407
459
|
Register emails list associated to the current user.
|
|
408
460
|
|
|
409
461
|
@param emails user's emails array
|
|
410
462
|
*/
|
|
411
|
-
- (void)setEmails:(NSArray *)emails;
|
|
463
|
+
- (void)setEmails:(NSArray * _Nonnull)emails;
|
|
412
464
|
|
|
413
465
|
/**
|
|
414
466
|
Register email associated to the current user. Email should be a string and could not be null or empty.
|
|
@@ -416,14 +468,14 @@ Unregisters from push notifications.
|
|
|
416
468
|
|
|
417
469
|
@param email user's email string
|
|
418
470
|
*/
|
|
419
|
-
- (void)setEmail:(NSString *)email completion:(void(^)(NSError * error))completion;
|
|
471
|
+
- (void)setEmail:(NSString * _Nonnull)email completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
|
|
420
472
|
|
|
421
473
|
/**
|
|
422
474
|
Register email associated to the current user. Email should be a string and could not be null or empty.
|
|
423
475
|
|
|
424
476
|
@param email user's email string
|
|
425
477
|
*/
|
|
426
|
-
- (void)setEmail:(NSString *)email;
|
|
478
|
+
- (void)setEmail:(NSString * _Nonnull)email;
|
|
427
479
|
|
|
428
480
|
/**
|
|
429
481
|
Move all events from oldUserId to newUserId if doMerge is true. If doMerge is false all events for oldUserId are removed.
|
|
@@ -433,7 +485,7 @@ Unregisters from push notifications.
|
|
|
433
485
|
@param doMerge if false all events for oldUserId are removed, if true all events for oldUserId are moved to newUserId
|
|
434
486
|
@param completion callback
|
|
435
487
|
*/
|
|
436
|
-
- (void)mergeUserId:(NSString *)oldUserId to:(NSString *)newUserId doMerge:(BOOL)doMerge completion:(void (^)(NSError *error))completion;
|
|
488
|
+
- (void)mergeUserId:(NSString * _Nonnull)oldUserId to:(NSString * _Nonnull)newUserId doMerge:(BOOL)doMerge completion:(void (^ _Nullable)(NSError * _Nullable error))completion;
|
|
437
489
|
|
|
438
490
|
/**
|
|
439
491
|
Starts communication with Pushwoosh server.
|
|
@@ -451,7 +503,7 @@ Unregisters from push notifications.
|
|
|
451
503
|
@param url Deep Link URL
|
|
452
504
|
*/
|
|
453
505
|
#if TARGET_OS_IOS || TARGET_OS_WATCH
|
|
454
|
-
- (BOOL)handleOpenURL:(NSURL *)url;
|
|
506
|
+
- (BOOL)handleOpenURL:(NSURL * _Nonnull)url;
|
|
455
507
|
#endif
|
|
456
508
|
|
|
457
509
|
@end
|
|
@@ -468,7 +520,7 @@ Unregisters from push notifications.
|
|
|
468
520
|
Returns UNUserNotificationCenterDelegate that handles foreground push notifications on iOS10
|
|
469
521
|
*/
|
|
470
522
|
#if TARGET_OS_IOS || TARGET_OS_WATCH
|
|
471
|
-
@property (nonatomic, strong, readonly) id<UNUserNotificationCenterDelegate> defaultNotificationCenterDelegate;
|
|
523
|
+
@property (nonatomic, strong, readonly) id<UNUserNotificationCenterDelegate> _Nonnull defaultNotificationCenterDelegate;
|
|
472
524
|
#elif TARGET_OS_OSX
|
|
473
525
|
@property (nonatomic, strong, readonly) id<NSUserNotificationCenterDelegate> defaultNotificationCenterDelegate;
|
|
474
526
|
#endif
|
|
@@ -477,7 +529,7 @@ Unregisters from push notifications.
|
|
|
477
529
|
Adds extra UNUserNotificationCenterDelegate that handles foreground push notifications on iOS10.
|
|
478
530
|
*/
|
|
479
531
|
#if TARGET_OS_IOS || TARGET_OS_WATCH
|
|
480
|
-
- (void)addNotificationCenterDelegate:(id<UNUserNotificationCenterDelegate>)delegate;
|
|
532
|
+
- (void)addNotificationCenterDelegate:(id<UNUserNotificationCenterDelegate> _Nonnull)delegate;
|
|
481
533
|
#endif
|
|
482
534
|
@end
|
|
483
535
|
|
|
@@ -504,7 +556,7 @@ Unregisters from push notifications.
|
|
|
504
556
|
|
|
505
557
|
@return Dictionary, that needs to be sent as the value for the tag
|
|
506
558
|
*/
|
|
507
|
-
+ (NSDictionary *)incrementalTagWithInteger:(NSInteger)delta;
|
|
559
|
+
+ (NSDictionary * _Nullable)incrementalTagWithInteger:(NSInteger)delta;
|
|
508
560
|
|
|
509
561
|
/**
|
|
510
562
|
Creates a dictionary for extending Tag’s values list with additional values
|
|
@@ -525,6 +577,6 @@ Unregisters from push notifications.
|
|
|
525
577
|
|
|
526
578
|
@return Dictionary to be sent as the value for the tag
|
|
527
579
|
*/
|
|
528
|
-
+ (NSDictionary *)appendValuesToListTag:(NSArray<NSString *> *)array;
|
|
580
|
+
+ (NSDictionary * _Nullable)appendValuesToListTag:(NSArray<NSString *> * _Nonnull)array;
|
|
529
581
|
|
|
530
582
|
@end
|
|
@@ -42,25 +42,25 @@ RCT_EXPORT_MODULE(Pushwoosh);
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)success error:(RCTResponseSenderBlock)error) {
|
|
45
|
-
|
|
45
|
+
NSString *appCode = config[@"pw_appid"];
|
|
46
46
|
NSString *notificationHandling = config[@"pw_notification_handling"];
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
if (!appCode || ![appCode isKindOfClass:[NSString class]]) {
|
|
49
|
+
if (error) {
|
|
50
|
+
error(@[ @"pw_appid is missing" ]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
55
|
|
|
56
56
|
NSString *proxyUrl = config[@"reverse_proxy_url"];
|
|
57
57
|
if (proxyUrl && ![proxyUrl isEqualToString:@""]) {
|
|
58
58
|
[[Pushwoosh sharedInstance] setReverseProxy:proxyUrl];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
[PushNotificationManager initializeWithAppCode:appCode appName:nil];
|
|
62
|
+
[[PushNotificationManager pushManager] sendAppOpen];
|
|
63
|
+
[PushNotificationManager pushManager].delegate = self;
|
|
64
64
|
|
|
65
65
|
// We set Pushwoosh UNUserNotificationCenter delegate unless CUSTOM is specified in the config
|
|
66
66
|
if(![notificationHandling isEqualToString:@"CUSTOM"]) {
|
|
@@ -71,7 +71,7 @@ RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)suc
|
|
|
71
71
|
success(@[]);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
if (gStartPushData) {
|
|
75
75
|
NSString *link = gStartPushData[@"l"];
|
|
76
76
|
|
|
77
77
|
//get deeplink from the payload and write it to the launchOptions for proper RCTLinking behavior
|
|
@@ -82,7 +82,7 @@ RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)suc
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
[self sendJSEvent:kPushReceivedJSEvent withArgs:gStartPushData];
|
|
85
|
-
|
|
85
|
+
[self sendJSEvent:kPushOpenJSEvent withArgs:gStartPushData];
|
|
86
86
|
} else if([PushNotificationManager pushManager].launchNotification) {
|
|
87
87
|
[self sendJSEvent:kPushReceivedJSEvent withArgs:[PushNotificationManager pushManager].launchNotification];
|
|
88
88
|
[self sendJSEvent:kPushOpenJSEvent withArgs:[PushNotificationManager pushManager].launchNotification];
|
|
@@ -90,10 +90,10 @@ RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)suc
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
RCT_EXPORT_METHOD(register:(RCTResponseSenderBlock)success error:(RCTResponseSenderBlock)error) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
[[PWEventDispatcher sharedDispatcher] subscribe:success toEvent:kRegistrationSuccesEvent];
|
|
94
|
+
[[PWEventDispatcher sharedDispatcher] subscribe:error toEvent:kRegistrationErrorEvent];
|
|
95
|
+
|
|
96
|
+
[[PushNotificationManager pushManager] registerForPushNotifications];
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
RCT_EXPORT_METHOD(unregister:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
|
|
@@ -109,13 +109,13 @@ RCT_EXPORT_METHOD(unregister:(RCTResponseSenderBlock)successCallback error:(RCTR
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
RCT_EXPORT_METHOD(onPushOpen:(RCTResponseSenderBlock)callback) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
[[PWEventDispatcher sharedDispatcher] subscribe:callback toEvent:kPushOpenEvent];
|
|
113
|
+
|
|
114
|
+
if (gStartPushData) {
|
|
115
|
+
NSDictionary *pushData = gStartPushData;
|
|
116
|
+
gStartPushData = nil;
|
|
117
|
+
[[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(pushData) ]];
|
|
118
|
+
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
RCT_EXPORT_METHOD(onPushReceived:(RCTResponseSenderBlock)callback) {
|
|
@@ -129,39 +129,39 @@ RCT_EXPORT_METHOD(onPushReceived:(RCTResponseSenderBlock)callback) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
RCT_EXPORT_METHOD(getHwid:(RCTResponseSenderBlock)callback) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
if (callback) {
|
|
133
|
+
callback(@[ [[PushNotificationManager pushManager] getHWID] ]);
|
|
134
|
+
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
RCT_EXPORT_METHOD(getPushToken:(RCTResponseSenderBlock)callback) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
if (callback) {
|
|
139
|
+
callback(@[ objectOrNull([[PushNotificationManager pushManager] getPushToken]) ]);
|
|
140
|
+
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
RCT_EXPORT_METHOD(setTags:(NSDictionary*)tags success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
[[PushNotificationManager pushManager] setTags:tags withCompletion:^(NSError* error) {
|
|
145
|
+
if (!error && successCallback) {
|
|
146
|
+
successCallback(@[]);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (error && errorCallback) {
|
|
150
|
+
errorCallback(@[ objectOrNull([error localizedDescription]) ]);
|
|
151
|
+
}
|
|
152
|
+
}];
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
RCT_EXPORT_METHOD(getTags:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
[[PushNotificationManager pushManager] loadTags:^(NSDictionary* tags) {
|
|
157
|
+
if (successCallback) {
|
|
158
|
+
successCallback(@[ tags ]);
|
|
159
|
+
}
|
|
160
|
+
} error:^(NSError *error) {
|
|
161
|
+
if (errorCallback) {
|
|
162
|
+
errorCallback(@[ objectOrNull([error localizedDescription]) ]);
|
|
163
|
+
}
|
|
164
|
+
}];
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
RCT_EXPORT_METHOD(setShowPushnotificationAlert:(BOOL)showPushnotificationAlert) {
|
|
@@ -175,7 +175,7 @@ RCT_EXPORT_METHOD(getShowPushnotificationAlert:(RCTResponseSenderBlock)callback)
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
RCT_EXPORT_METHOD(setUserId:(NSString*)userId) {
|
|
178
|
-
|
|
178
|
+
[[PWInAppManager sharedManager] setUserId:userId];
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
RCT_EXPORT_METHOD(setUserId:(NSString*)userId success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
|
|
@@ -192,7 +192,7 @@ RCT_EXPORT_METHOD(setUserId:(NSString*)userId success:(RCTResponseSenderBlock)su
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
RCT_EXPORT_METHOD(postEvent:(NSString*)event withAttributes:(NSDictionary*)attributes) {
|
|
195
|
-
|
|
195
|
+
[[PWInAppManager sharedManager] postEvent:event withAttributes:attributes];
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
RCT_EXPORT_METHOD(setApplicationIconBadgeNumber:(nonnull NSNumber*)badgeNumber) {
|
|
@@ -206,11 +206,11 @@ RCT_EXPORT_METHOD(setLanguage:(NSString *)language) {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
RCT_EXPORT_METHOD(getApplicationIconBadgeNumber:(RCTResponseSenderBlock)callback) {
|
|
209
|
-
|
|
209
|
+
if(callback) {
|
|
210
210
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
211
211
|
callback(@[ @([UIApplication sharedApplication].applicationIconBadgeNumber) ]);
|
|
212
212
|
});
|
|
213
|
-
|
|
213
|
+
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
RCT_EXPORT_METHOD(addToApplicationIconBadgeNumber:(nonnull NSNumber*)badgeNumber) {
|
|
@@ -239,6 +239,98 @@ RCT_EXPORT_METHOD(presentInboxUI:(NSDictionary *)styleDictionary) {
|
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
RCT_EXPORT_METHOD(messagesWithNoActionPerformedCount:(RCTResponseSenderBlock)callback) {
|
|
243
|
+
[PWInbox messagesWithNoActionPerformedCountWithCompletion:^(NSInteger count, NSError *error) {
|
|
244
|
+
if (callback) {
|
|
245
|
+
callback(@[ @(count) ]);
|
|
246
|
+
}
|
|
247
|
+
}];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
RCT_EXPORT_METHOD(unreadMessagesCount:(RCTResponseSenderBlock)callback) {
|
|
251
|
+
[PWInbox unreadMessagesCountWithCompletion:^(NSInteger count, NSError *error) {
|
|
252
|
+
if (callback) {
|
|
253
|
+
callback(@[ @(count) ]);
|
|
254
|
+
}
|
|
255
|
+
}];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
RCT_EXPORT_METHOD(messagesCount:(RCTResponseSenderBlock)callback) {
|
|
259
|
+
[PWInbox messagesCountWithCompletion:^(NSInteger count, NSError *error) {
|
|
260
|
+
if (callback) {
|
|
261
|
+
callback(@[ @(count) ]);
|
|
262
|
+
}
|
|
263
|
+
}];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
RCT_EXPORT_METHOD(loadMessages:(RCTResponseSenderBlock)success fail:(RCTResponseSenderBlock)fail) {
|
|
267
|
+
[PWInbox loadMessagesWithCompletion:^(NSArray<NSObject<PWInboxMessageProtocol> *> *messages, NSError *error) {
|
|
268
|
+
if (success) {
|
|
269
|
+
NSMutableArray* array = [[NSMutableArray alloc] init];
|
|
270
|
+
for (NSObject<PWInboxMessageProtocol>* message in messages) {
|
|
271
|
+
NSDictionary* dict = [self inboxMessageToDictionary:message];
|
|
272
|
+
[array addObject:dict];
|
|
273
|
+
}
|
|
274
|
+
success( @[ array ]);
|
|
275
|
+
} else if (error != nil && fail != nil) {
|
|
276
|
+
fail(@[ error ]);
|
|
277
|
+
}
|
|
278
|
+
}];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
RCT_EXPORT_METHOD(readMessage:(NSString*)code) {
|
|
282
|
+
NSArray* arr = [NSArray arrayWithObject:code];
|
|
283
|
+
[PWInbox readMessagesWithCodes:arr];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
RCT_EXPORT_METHOD(readMessages:(NSArray<NSString*>*)codes) {
|
|
287
|
+
[PWInbox readMessagesWithCodes:codes];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
RCT_EXPORT_METHOD(deleteMessage:(NSString*)code) {
|
|
291
|
+
NSArray* arr = [NSArray arrayWithObject:code];
|
|
292
|
+
[PWInbox deleteMessagesWithCodes:arr];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
RCT_EXPORT_METHOD(deleteMessages:(NSArray<NSString*>*)codes) {
|
|
296
|
+
[PWInbox deleteMessagesWithCodes:codes];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
RCT_EXPORT_METHOD(performAction:(NSString*)code) {
|
|
300
|
+
[PWInbox performActionForMessageWithCode:code];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
- (NSDictionary*)inboxMessageToDictionary:(NSObject<PWInboxMessageProtocol>*) message {
|
|
304
|
+
NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
|
|
305
|
+
[dictionary setValue:@(message.type) forKey:@"type"];
|
|
306
|
+
[dictionary setValue:[self stringOrEmpty: message.imageUrl] forKey:@"imageUrl"];
|
|
307
|
+
[dictionary setValue:[self stringOrEmpty: message.code] forKey:@"code"];
|
|
308
|
+
[dictionary setValue:[self stringOrEmpty: message.title] forKey:@"title"];
|
|
309
|
+
[dictionary setValue:[self stringOrEmpty: message.message] forKey:@"message"];
|
|
310
|
+
[dictionary setValue:[self stringOrEmpty: [self dateToString:message.sendDate]] forKey:@"sendDate"];
|
|
311
|
+
[dictionary setValue:@(message.isRead) forKey:@"isRead"];
|
|
312
|
+
[dictionary setValue:@(message.isActionPerformed) forKey:@"isActionPerformed"];
|
|
313
|
+
|
|
314
|
+
NSDictionary* actionParams = [NSDictionary dictionaryWithDictionary:message.actionParams];
|
|
315
|
+
NSData* customData = [actionParams valueForKey:@"u"];
|
|
316
|
+
[dictionary setValue:customData forKey:@"customData"];
|
|
317
|
+
|
|
318
|
+
NSDictionary* result = [NSDictionary dictionaryWithDictionary:dictionary];
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
- (NSString *)stringOrEmpty:(NSString *)string {
|
|
323
|
+
return string != nil ? string : @"";
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
- (NSString*)dateToString:(NSDate*)date {
|
|
327
|
+
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
|
328
|
+
[formatter setFormatterBehavior:NSDateFormatterBehaviorDefault];
|
|
329
|
+
[formatter setDateStyle:NSDateFormatterFullStyle];
|
|
330
|
+
[formatter setTimeStyle:NSDateFormatterMediumStyle];
|
|
331
|
+
return [formatter stringFromDate:date];
|
|
332
|
+
}
|
|
333
|
+
|
|
242
334
|
- (PWIInboxStyle *)inboxStyleForDictionary:(NSDictionary *)styleDictionary {
|
|
243
335
|
PWIInboxStyle *style = [PWIInboxStyle defaultStyle];
|
|
244
336
|
|
|
@@ -484,11 +576,11 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
|
|
|
484
576
|
#pragma mark - PushNotificationDelegate
|
|
485
577
|
|
|
486
578
|
- (void)onDidRegisterForRemoteNotificationsWithDeviceToken:(NSString *)token {
|
|
487
|
-
|
|
579
|
+
[[PWEventDispatcher sharedDispatcher] dispatchEvent:kRegistrationSuccesEvent withArgs:@[ objectOrNull(token) ]];
|
|
488
580
|
}
|
|
489
581
|
|
|
490
582
|
- (void)onDidFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
|
491
|
-
|
|
583
|
+
[[PWEventDispatcher sharedDispatcher] dispatchEvent:kRegistrationErrorEvent withArgs:@[ objectOrNull([error localizedDescription]) ]];
|
|
492
584
|
}
|
|
493
585
|
|
|
494
586
|
- (void)onPushReceived:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
|
|
@@ -498,20 +590,20 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
|
|
|
498
590
|
}
|
|
499
591
|
|
|
500
592
|
- (void)onPushAccepted:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
|
|
501
|
-
|
|
502
|
-
|
|
593
|
+
[[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(pushNotification) ]];
|
|
594
|
+
|
|
503
595
|
[self sendJSEvent:kPushOpenJSEvent withArgs:pushNotification];
|
|
504
596
|
}
|
|
505
597
|
|
|
506
598
|
#pragma mark - RCTEventEmitter
|
|
507
599
|
|
|
508
600
|
- (void)sendJSEvent:(NSString*)event withArgs:(NSDictionary*)args {
|
|
509
|
-
//
|
|
510
|
-
|
|
601
|
+
// [self sendEventWithName:event body:args];
|
|
602
|
+
[self.bridge.eventDispatcher sendDeviceEventWithName:event body:args];
|
|
511
603
|
}
|
|
512
604
|
|
|
513
605
|
- (NSArray<NSString *> *)supportedEvents {
|
|
514
|
-
|
|
606
|
+
return @[ kPushOpenJSEvent ];
|
|
515
607
|
}
|
|
516
608
|
|
|
517
609
|
@end
|
|
@@ -519,7 +611,7 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
|
|
|
519
611
|
@implementation UIApplication (InternalPushRuntime)
|
|
520
612
|
|
|
521
613
|
- (BOOL)pushwooshUseRuntimeMagic {
|
|
522
|
-
|
|
614
|
+
return YES;
|
|
523
615
|
}
|
|
524
616
|
|
|
525
617
|
// Just keep the launch notification until the module starts and callback functions initalizes
|
|
@@ -529,13 +621,13 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
|
|
|
529
621
|
}
|
|
530
622
|
}
|
|
531
623
|
- (void)onPushAccepted:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
624
|
+
if (onStart) {
|
|
625
|
+
gStartPushData = pushNotification;
|
|
626
|
+
}
|
|
535
627
|
}
|
|
536
628
|
|
|
537
629
|
- (NSObject<PushNotificationDelegate> *)getPushwooshDelegate {
|
|
538
|
-
|
|
630
|
+
return (NSObject<PushNotificationDelegate> *)self;
|
|
539
631
|
}
|
|
540
632
|
|
|
541
633
|
@end
|
package/src/ios/libPushwoosh.a
CHANGED
|
Binary file
|