pushwoosh-react-native-plugin 2.0.0 → 2.2.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.
Files changed (66) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +135 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.yml +31 -0
  3. package/.github/ISSUE_TEMPLATE/question.yml +28 -0
  4. package/InlineInApp.js +71 -0
  5. package/README.md +35 -85
  6. package/docs/README.md +230 -11
  7. package/index.d.ts +91 -0
  8. package/index.js +265 -24
  9. package/package.json +12 -1
  10. package/pushwoosh-react-native-plugin.podspec +20 -0
  11. package/react-native.config.js +9 -0
  12. package/scripts/add_inbox_ios_resources.js +42 -0
  13. package/src/android/build.gradle +40 -10
  14. package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  15. package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  16. package/src/android/gradlew +160 -0
  17. package/src/android/gradlew.bat +90 -0
  18. package/src/android/src/main/AndroidManifest.xml +19 -54
  19. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/ConversionUtil.java +214 -148
  20. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/CustomFirebaseMessagingService.java +29 -0
  21. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/EventDispatcher.java +7 -6
  22. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InboxUiStyleManager.java +162 -0
  23. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InlineInAppManager.java +48 -0
  24. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshNotificationServiceExtension.java +44 -0
  25. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPackage.java +4 -2
  26. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java +606 -393
  27. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/RCTInlineInAppView.java +75 -0
  28. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/internal/ReactNativePluginProvider.java +15 -0
  29. package/src/ios/PWAppDelegate.h +20 -0
  30. package/src/ios/PWGDPRManager.h +46 -0
  31. package/src/ios/PWIInboxStyle.h +122 -0
  32. package/src/ios/PWIInboxUI.h +39 -0
  33. package/src/ios/PWInAppManager.h +176 -0
  34. package/src/ios/PWInbox.h +147 -0
  35. package/src/ios/PWInlineInAppView.h +26 -0
  36. package/src/ios/PWLog.h +23 -0
  37. package/src/ios/PWMessaging.h +20 -0
  38. package/src/ios/PWNotificationExtensionManager.h +46 -0
  39. package/src/ios/PWRichMediaManager.h +123 -0
  40. package/src/ios/PWRichMediaStyle.h +122 -0
  41. package/src/ios/PushNotificationManager.h +234 -111
  42. package/src/ios/Pushwoosh.h +623 -0
  43. package/src/ios/PushwooshInboxBundle.bundle/Info.plist +0 -0
  44. package/src/ios/PushwooshInboxBundle.bundle/PWIInboxAttachmentViewController.nib +0 -0
  45. package/src/ios/PushwooshInboxBundle.bundle/PWIInboxMessageViewCell.nib +0 -0
  46. package/src/ios/PushwooshInboxBundle.bundle/PWIInboxViewController.nib +0 -0
  47. package/src/ios/PushwooshInboxBundle.bundle/errorMessage@2x.png +0 -0
  48. package/src/ios/PushwooshInboxBundle.bundle/inbox_icon.png +0 -0
  49. package/src/ios/PushwooshInboxBundle.bundle/noMessage@2x.png +0 -0
  50. package/src/ios/PushwooshInboxBundle.bundle/unread.png +0 -0
  51. package/src/ios/PushwooshInboxUI.h +19 -0
  52. package/src/ios/PushwooshPlugin/PWEventDispatcher.h +1 -1
  53. package/src/ios/PushwooshPlugin/PWInlineInAppManager.h +17 -0
  54. package/src/ios/PushwooshPlugin/PWInlineInAppManager.m +54 -0
  55. package/src/ios/PushwooshPlugin/Pushwoosh.h +18 -3
  56. package/src/ios/PushwooshPlugin/Pushwoosh.m +532 -98
  57. package/src/ios/PushwooshPlugin.xcodeproj/project.pbxproj +27 -6
  58. package/src/ios/libPushwoosh.a +0 -0
  59. package/src/ios/libPushwooshInboxUI.a +0 -0
  60. package/.npmignore +0 -3
  61. package/src/android/.npmignore +0 -1
  62. package/src/android/pushwooshplugin.iml +0 -150
  63. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/NotificationReceiver.java +0 -42
  64. package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PostEventActivity.java +0 -45
  65. package/src/ios/Pushwoosh.a +0 -0
  66. package/src/ios/PushwooshPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
@@ -0,0 +1,75 @@
1
+ package com.pushwoosh.reactnativeplugin;
2
+
3
+ import android.content.Context;
4
+ import android.view.Choreographer;
5
+ import android.view.View;
6
+
7
+ import com.facebook.react.bridge.Arguments;
8
+ import com.facebook.react.bridge.ReactContext;
9
+ import com.facebook.react.bridge.WritableMap;
10
+ import com.facebook.react.uimanager.events.RCTEventEmitter;
11
+ import com.pushwoosh.inapp.view.inline.InlineInAppView;
12
+ import com.pushwoosh.inapp.view.inline.InlineInAppViewListener;
13
+
14
+ public class RCTInlineInAppView extends InlineInAppView implements InlineInAppViewListener {
15
+ public RCTInlineInAppView(Context context) {
16
+ super(context);
17
+ this.addInlineInAppViewListener(this);
18
+ setupLayoutHack();
19
+ }
20
+
21
+ void setupLayoutHack() {
22
+ Choreographer.getInstance().postFrameCallback(new Choreographer.FrameCallback() {
23
+ @Override
24
+ public void doFrame(long frameTimeNanos) {
25
+ manuallyLayoutChildren();
26
+ getViewTreeObserver().dispatchOnGlobalLayout();
27
+ Choreographer.getInstance().postFrameCallback(this);
28
+ }
29
+ });
30
+
31
+ }
32
+
33
+ void manuallyLayoutChildren() {
34
+ for (int i = 0; i < getChildCount(); i++) {
35
+ View child = getChildAt(i);
36
+ child.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
37
+ MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
38
+ child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
39
+ }
40
+ }
41
+
42
+ @Override
43
+ public void onInlineInAppLoaded() {
44
+ WritableMap event = Arguments.createMap();
45
+ event.putString("identifier", this.getIdentifier());
46
+ ReactContext reactContext = (ReactContext)getContext();
47
+ reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
48
+ getId(),
49
+ "onLoaded",
50
+ event);
51
+ }
52
+
53
+ @Override
54
+ public void onInlineInAppViewClosed() {
55
+ WritableMap event = Arguments.createMap();
56
+ event.putString("identifier", this.getIdentifier());
57
+ ReactContext reactContext = (ReactContext)getContext();
58
+ reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
59
+ getId(),
60
+ "onClosed",
61
+ event);
62
+ }
63
+
64
+ @Override
65
+ public void onInlineInAppViewChangedSize(int var1, int var2) {
66
+ WritableMap event = Arguments.createMap();
67
+ event.putString("width", String.valueOf(var1));
68
+ event.putString("height", String.valueOf(var2));
69
+ ReactContext reactContext = (ReactContext)getContext();
70
+ reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
71
+ getId(),
72
+ "onSizeChanged",
73
+ event);
74
+ }
75
+ }
@@ -0,0 +1,15 @@
1
+ package com.pushwoosh.reactnativeplugin.internal;
2
+
3
+ import com.pushwoosh.internal.PluginProvider;
4
+
5
+ public class ReactNativePluginProvider implements PluginProvider {
6
+ @Override
7
+ public String getPluginType() {
8
+ return "React Native";
9
+ }
10
+
11
+ @Override
12
+ public int richMediaStartDelay() {
13
+ return DEFAULT_RICH_MEDIA_START_DELAY;
14
+ }
15
+ }
@@ -0,0 +1,20 @@
1
+ //
2
+ // PWAppDelegate.h
3
+ // Pushwoosh SDK
4
+ // (c) Pushwoosh 2018
5
+ //
6
+
7
+ #if TARGET_OS_IPHONE
8
+
9
+ #import <UIKit/UIKit.h>
10
+
11
+ /*
12
+ Base AppDelegate class for easier integration.
13
+ */
14
+ @interface PWAppDelegate : UIResponder <UIApplicationDelegate>
15
+
16
+ @property (nonatomic, strong) UIWindow *window;
17
+
18
+ @end
19
+
20
+ #endif
@@ -0,0 +1,46 @@
1
+ //
2
+ // PWGDPRManager.h
3
+ // Pushwoosh SDK
4
+ // (c) Pushwoosh 2018
5
+ //
6
+
7
+ #import <Foundation/Foundation.h>
8
+
9
+ /*
10
+ `PWGDPRManager` class offers access to the singleton-instance of the manager responsible for channels management required by GDPR.
11
+ */
12
+
13
+ FOUNDATION_EXPORT NSString * const PWGDPRStatusDidChangeNotification;
14
+
15
+ @interface PWGDPRManager : NSObject
16
+
17
+ /**
18
+ Indicates availability of the GDPR compliance solution.
19
+ */
20
+ @property (nonatomic, readonly, getter=isAvailable) BOOL available;
21
+
22
+ @property (nonatomic, readonly, getter=isCommunicationEnabled) BOOL communicationEnabled;
23
+
24
+ @property (nonatomic, readonly, getter=isDeviceDataRemoved) BOOL deviceDataRemoved;
25
+
26
+ + (instancetype)sharedManager;
27
+
28
+ /**
29
+ Enable/disable all communication with Pushwoosh. Enabled by default.
30
+ */
31
+ - (void)setCommunicationEnabled:(BOOL)enabled completion:(void (^)(NSError *error))completion;
32
+
33
+ /**
34
+ Removes all device data from Pushwoosh and stops all interactions and communication permanently.
35
+ */
36
+ - (void)removeAllDeviceDataWithCompletion:(void (^)(NSError *error))completion;
37
+
38
+ #if TARGET_OS_IOS || TARGET_OS_OSX
39
+
40
+ - (void)showGDPRConsentUI;
41
+
42
+ - (void)showGDPRDeletionUI;
43
+
44
+ #endif
45
+
46
+ @end
@@ -0,0 +1,122 @@
1
+ //
2
+ // PWIInboxStyle.h
3
+ // PushwooshInboxUI
4
+ //
5
+ // Created by Pushwoosh on 01/11/2017.
6
+ // Copyright © 2017 Pushwoosh. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import <UIKit/UIKit.h>
11
+
12
+ typedef NSString * (^PWIDateFormatterBlock)(NSDate *date, NSObject *owner);
13
+
14
+ //! This class is designed to customize the Inbox appearance
15
+ @interface PWIInboxStyle : NSObject
16
+
17
+ //! This block customizes the date formatting
18
+ @property (nonatomic, readwrite) PWIDateFormatterBlock dateFormatterBlock;
19
+
20
+ //! The default icon in the cell next to the message; if not specified, the app icon is used
21
+ @property (nonatomic, readwrite) UIImage *defaultImageIcon;
22
+
23
+ //! The default font
24
+ @property (nonatomic, readwrite) UIFont *defaultFont;
25
+
26
+ //! The default text color
27
+ @property (nonatomic, readwrite) UIColor *defaultTextColor;
28
+
29
+ //! The text color of a read notification
30
+ @property (nonatomic, readwrite) UIColor *readTextColor;
31
+
32
+ //! The default background color
33
+ @property (nonatomic, readwrite) UIColor *backgroundColor;
34
+
35
+ //! The default selection color
36
+ @property (nonatomic, readwrite) UIColor *selectionColor;
37
+
38
+ //! The appearance of the unread messages mark
39
+ @property (nonatomic, readwrite) UIImage *unreadImage;
40
+
41
+ //! The image which is displayed if an error occurs and the list of inbox messages is empty
42
+ @property (nonatomic, readwrite) UIImage *listErrorImage;
43
+
44
+ //! The error text which is displayed when an error occurs; cannot be localized
45
+ @property (nonatomic, readwrite) NSString *listErrorMessage;
46
+
47
+ //! The image which is displayed if the list of inbox messages is empty
48
+ @property (nonatomic, readwrite) UIImage *listEmptyImage;
49
+
50
+ //! The text which is displayed if the list of inbox messages is empty; cannot be localized
51
+ @property (nonatomic, readwrite) NSString *listEmptyMessage;
52
+
53
+ //! The accent color
54
+ @property (nonatomic, readwrite) UIColor *accentColor;
55
+
56
+ //! The color of message titles
57
+ @property (nonatomic, readwrite) UIColor *titleColor;
58
+
59
+ //! The title color for read notifications
60
+ @property (nonatomic, readwrite) UIColor *readTitleColor;
61
+
62
+ //! The color of messages descriptions
63
+ @property (nonatomic, readwrite) UIColor *descriptionColor;
64
+
65
+ //! The color of message dates
66
+ @property (nonatomic, readwrite) UIColor *dateColor;
67
+
68
+ //! The color of the separator
69
+ @property (nonatomic, readwrite) UIColor *separatorColor;
70
+
71
+ //! The font of message titles
72
+ @property (nonatomic, readwrite) UIFont *titleFont;
73
+
74
+ //! The font of message descriptions
75
+ @property (nonatomic, readwrite) UIFont *descriptionFont;
76
+
77
+ //! The font of message dates
78
+ @property (nonatomic, readwrite) UIFont *dateFont;
79
+
80
+ //! The default bar color
81
+ @property (nonatomic, readwrite) UIColor *barBackgroundColor;
82
+
83
+ //! The default back button color
84
+ @property(nonatomic, readwrite) UIColor *barAccentColor;
85
+
86
+ //! The default bar accent color
87
+ @property (nonatomic, readwrite) UIColor *barTextColor;
88
+
89
+ //! The default bar title text
90
+ @property (nonatomic, readwrite) NSString *barTitle;
91
+
92
+ /**
93
+ The method returning the default style; all parameters might be changed
94
+
95
+ @retutn instance of default style
96
+ */
97
+ + (instancetype)defaultStyle;
98
+
99
+ /**
100
+ This method updates the default style for PWInboxViewController
101
+
102
+ @param style the new default style for PWInboxViewController
103
+ */
104
+ + (void)setupDefaultStyle:(PWIInboxStyle *)style;
105
+
106
+ /**
107
+ The method filling style's fields based on following parameters: icon, textColor, accentColor, date; all parameters might be changed
108
+ */
109
+ + (instancetype)customStyleWithDefaultImageIcon:(UIImage *)icon
110
+ textColor:(UIColor *)textColor
111
+ accentColor:(UIColor *)accentColor
112
+ font:(UIFont *)font;
113
+ /**
114
+ The method filling style's fields based on following parameters: icon, textColor, accentColor, font, dateFormatterBlock; all parameters might be changed
115
+ */
116
+ + (instancetype)customStyleWithDefaultImageIcon:(UIImage *)icon
117
+ textColor:(UIColor *)textColor
118
+ accentColor:(UIColor *)accentColor
119
+ font:(UIFont *)font
120
+ dateFromatterBlock:(PWIDateFormatterBlock)dateFormatterBlock;
121
+
122
+ @end
@@ -0,0 +1,39 @@
1
+ //
2
+ // PWIInboxUI.h
3
+ // PushwooshInboxUI
4
+ //
5
+ // Created by Pushwoosh on 01/11/2017.
6
+ // Copyright © 2017 Pushwoosh. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import <UIKit/UIKit.h>
11
+
12
+ @protocol PWInboxMessageProtocol;
13
+
14
+ @interface PWIInboxViewController : UIViewController
15
+
16
+ @property (nonatomic) void (^onMessageClickBlock)(id<PWInboxMessageProtocol> message);
17
+
18
+ /**
19
+ Reloads everything from scratch.
20
+ */
21
+ - (void)reloadData;
22
+ - (instancetype)init NS_UNAVAILABLE;
23
+
24
+ @end
25
+
26
+ @class PWIInboxStyle;
27
+ @interface PWIInboxUI : NSObject
28
+
29
+ /**
30
+ @return PWIInboxViewController with a specified style
31
+ */
32
+ + (PWIInboxViewController *)createInboxControllerWithStyle:(PWIInboxStyle *)style;
33
+
34
+ /**
35
+ @return PWIInboxViewController with a specified style and height of table view
36
+ */
37
+ + (PWIInboxViewController *)createInboxControllerWithStyle:(PWIInboxStyle *)style andContentHeight:(CGFloat)contentHeight;
38
+
39
+ @end
@@ -0,0 +1,176 @@
1
+ //
2
+ // PWInAppManager.h
3
+ // Pushwoosh SDK
4
+ // (c) Pushwoosh 2017
5
+ //
6
+
7
+ #import <Foundation/Foundation.h>
8
+
9
+ #if TARGET_OS_IOS
10
+
11
+ #import <WebKit/WebKit.h>
12
+ /**
13
+ `PWJavaScriptInterface` protocol is a representation of Javascript object that can be added at runtime into In-App Message HTML page
14
+ to provide native calls and callbacks to Objective-C/Swift.
15
+
16
+ Example:
17
+
18
+ Objective-C:
19
+ @code
20
+ @implementation JavaScriptInterface
21
+
22
+ - (void)nativeCall:(NSString*)str :(PWJavaScriptCallback*)callback {
23
+ [callback executeWithParam:str];
24
+ }
25
+
26
+ @end
27
+
28
+ ...
29
+
30
+ [[PWInAppManager sharedManager] addJavascriptInterface:[JavaScriptInterface new] withName:@"ObjC"];
31
+ @endcode
32
+
33
+ JavaScript:
34
+ @code
35
+ ObjC.nativeCall("exampleString", function(str) {
36
+ console.log(str);
37
+ });
38
+ @endcode
39
+ */
40
+ @protocol PWJavaScriptInterface
41
+
42
+ @optional
43
+
44
+ /**
45
+ Tells the delegate that In-App Message load stated
46
+ */
47
+ - (void)onWebViewStartLoad:(WKWebView *)webView;
48
+
49
+ /**
50
+ Tells the delegate that In-App Message load finished
51
+ */
52
+ - (void)onWebViewFinishLoad:(WKWebView *)webView;
53
+
54
+ /**
55
+ Tells the delegate that In-App Message is closing
56
+ */
57
+ - (void)onWebViewStartClose:(WKWebView *)webView;
58
+
59
+ @end
60
+
61
+ /**
62
+ `PWJavaScriptCallback` is a representation of Javascript function
63
+ */
64
+ @interface PWJavaScriptCallback : NSObject
65
+
66
+ /**
67
+ Invokes callback with no arguments
68
+ */
69
+ - (NSString*) execute;
70
+
71
+ /**
72
+ Invokes callback with one argument
73
+ */
74
+ - (NSString*) executeWithParam: (NSString*) param;
75
+
76
+ /**
77
+ Invokes callback with multiple arguments
78
+ */
79
+ - (NSString*) executeWithParams: (NSArray*) params;
80
+
81
+ @end
82
+
83
+ #endif
84
+
85
+
86
+ /*
87
+ `PWInAppManager` class offers access to the singleton-instance of the inapp messages manager responsible for sending events and managing inapp message notifications.
88
+ */
89
+ @interface PWInAppManager : NSObject
90
+
91
+ + (instancetype)sharedManager;
92
+
93
+ + (void)updateInAppManagerInstance;
94
+
95
+ #if TARGET_OS_IOS || TARGET_OS_OSX
96
+ /**
97
+ Resets capping of the Pushwoosh out-of-the-box In-App solutions.
98
+ */
99
+ - (void)resetBusinessCasesFrequencyCapping;
100
+
101
+ #endif
102
+ /**
103
+ Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
104
+ This allows data and events to be matched across multiple user devices.
105
+ */
106
+ - (void)setUserId:(NSString *)userId;
107
+
108
+ /**
109
+ Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
110
+ This allows data and events to be matched across multiple user devices.
111
+ If setUser succeeds competion is called with nil argument. If setUser fails completion is called with error.
112
+ */
113
+ - (void)setUserId:(NSString *)userId completion:(void(^)(NSError * error))completion;
114
+
115
+ /**
116
+ Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
117
+ This allows data and events to be matched across multiple user devices.
118
+
119
+ @param userId user identifier
120
+ @param emails user's emails array
121
+ */
122
+ - (void)setUser:(NSString *)userId emails:(NSArray *)emails completion:(void(^)(NSError * error))completion;
123
+
124
+ /**
125
+ Register emails list associated to the current user.
126
+
127
+ @param emails user's emails array
128
+ */
129
+ - (void)setEmails:(NSArray *)emails completion:(void(^)(NSError * error))completion;
130
+
131
+ /**
132
+ Move all events from oldUserId to newUserId if doMerge is true. If doMerge is false all events for oldUserId are removed.
133
+
134
+ @param oldUserId source user
135
+ @param newUserId destination user
136
+ @param doMerge if false all events for oldUserId are removed, if true all events for oldUserId are moved to newUserId
137
+ @param completion callback
138
+ */
139
+ - (void)mergeUserId:(NSString *)oldUserId to:(NSString *)newUserId doMerge:(BOOL)doMerge completion:(void (^)(NSError *error))completion;
140
+
141
+ /**
142
+ Post events for In-App Messages. This can trigger In-App message display as specified in Pushwoosh Control Panel.
143
+
144
+ Example:
145
+ @code
146
+ [[PWInAppManager sharedManager] setUserId:@"96da2f590cd7246bbde0051047b0d6f7"];
147
+ [[PWInAppManager sharedManager] postEvent:@"buttonPressed" withAttributes:@{ @"buttonNumber" : @"4", @"buttonLabel" : @"Banner" } completion:nil];
148
+ @endcode
149
+
150
+ @param event name of the event
151
+ @param attributes NSDictionary of event attributes
152
+ @param completion function to call after posting event
153
+ */
154
+ - (void)postEvent:(NSString *)event withAttributes:(NSDictionary *)attributes completion:(void (^)(NSError *error))completion;
155
+
156
+ /**
157
+ See `postEvent:withAttributes:completion:`
158
+ */
159
+ - (void)postEvent:(NSString *)event withAttributes:(NSDictionary *)attributes;
160
+
161
+ #if TARGET_OS_IOS
162
+
163
+ /**
164
+ Adds javascript interface for In-App Messages. Interface will be accessible from javascript as object with specified `name` and functions defined in `interface` class.
165
+ */
166
+ - (void)addJavascriptInterface:(NSObject<PWJavaScriptInterface>*)interface withName:(NSString*)name;
167
+
168
+ /**
169
+ Updates In-App messages storage on a device
170
+ */
171
+
172
+ - (void)reloadInAppsWithCompletion: (void (^)(NSError *error))completion;
173
+
174
+ #endif
175
+
176
+ @end
@@ -0,0 +1,147 @@
1
+ //
2
+ // PWInbox.h
3
+ // Pushwoosh SDK
4
+ // (c) Pushwoosh 2017
5
+ //
6
+
7
+ #import <Foundation/Foundation.h>
8
+
9
+
10
+ /**
11
+ The notification arriving on the Inbox messages renewal
12
+ */
13
+ FOUNDATION_EXPORT NSString * const PWInboxMessagesDidUpdateNotification;
14
+
15
+ /**
16
+ The notification arriving when a push message is added to Inbox
17
+ */
18
+ FOUNDATION_EXPORT NSString * const PWInboxMessagesDidReceiveInPushNotification;
19
+
20
+ /**
21
+ The Inbox message type. Plain = without any action, Richmedia = contains a Rich media page, URL = contains remote URL, Deeplink = contains Deeplink
22
+ */
23
+ typedef NS_ENUM(NSInteger, PWInboxMessageType) {
24
+ PWInboxMessageTypePlain = 0,
25
+ PWInboxMessageTypeRichmedia = 1,
26
+ PWInboxMessageTypeURL = 2,
27
+ PWInboxMessageTypeDeeplink = 3
28
+ };
29
+
30
+
31
+ /**
32
+ `PWInboxMessageProtocol` The protocol describing the Inbox message.
33
+ */
34
+ @protocol PWInboxMessageProtocol <NSObject>
35
+
36
+ @required
37
+
38
+ @property (readonly, nonatomic) NSString *code;
39
+ @property (readonly, nonatomic) NSString *title;
40
+ @property (readonly, nonatomic) NSString *imageUrl;
41
+ @property (readonly, nonatomic) NSString *message;
42
+ @property (readonly, nonatomic) NSDate *sendDate;
43
+ @property (readonly, nonatomic) PWInboxMessageType type;
44
+ //! Inbox Message which is read, see + (void)readMessagesWithCodes:(NSArray<NSString *> *)codes
45
+ @property (readonly, nonatomic) BOOL isRead;
46
+ //! Action of the Inbox Message is performed (if true, an action was performed in the Inbox see + (void)performActionForMessageWithCode:(NSString *)code or an action was performed on the push tap )
47
+ @property (readonly, nonatomic) BOOL isActionPerformed;
48
+ @property (readonly, nonatomic) NSDictionary *actionParams;
49
+ @property (readonly, nonatomic) NSString *attachmentUrl;
50
+
51
+ @end
52
+
53
+ @interface PWInbox : NSObject
54
+
55
+ - (instancetype)init NS_UNAVAILABLE;
56
+
57
+ /**
58
+ Get the number of the PWInboxMessageProtocol with no action performed
59
+
60
+ @param completion - if successful, return the number of the InboxMessages with no action performed. Otherwise, return error
61
+ */
62
+ + (void)messagesWithNoActionPerformedCountWithCompletion:(void (^)(NSInteger count, NSError *error))completion;
63
+
64
+ /**
65
+ Get the number of the unread PWInboxMessageProtocol
66
+
67
+ @param completion - if successful, return the number of the unread InboxMessages. Otherwise, return error
68
+ */
69
+ + (void)unreadMessagesCountWithCompletion:(void (^)(NSInteger count, NSError *error))completion;
70
+
71
+ /**
72
+ Get the total number of the PWInboxMessageProtocol
73
+
74
+ @param completion - if successful, return the total number of the InboxMessages. Otherwise, return error
75
+ */
76
+ + (void)messagesCountWithCompletion:(void (^)(NSInteger count, NSError *error))completion;
77
+
78
+ /**
79
+ Get the collection of the PWInboxMessageProtocol that the user received
80
+
81
+ @param completion - if successful, return the collection of the InboxMessages. Otherwise, return error
82
+ */
83
+ + (void)loadMessagesWithCompletion:(void (^)(NSArray<NSObject<PWInboxMessageProtocol> *> *messages, NSError *error))completion;
84
+
85
+ /**
86
+ Call this method to mark the list of InboxMessageProtocol as read
87
+
88
+ @param codes of the inboxMessages
89
+ */
90
+ + (void)readMessagesWithCodes:(NSArray<NSString *> *)codes;
91
+
92
+ /**
93
+ Call this method, when the user clicks on the InboxMessageProtocol and the message’s action is performed
94
+
95
+ @param code of the inboxMessage that the user tapped
96
+ */
97
+ + (void)performActionForMessageWithCode:(NSString *)code;
98
+
99
+ /**
100
+ Call this method, when the user deletes the list of InboxMessageProtocol manually
101
+
102
+ @param codes of the list of InboxMessageProtocol.code that the user deleted
103
+ */
104
+ + (void)deleteMessagesWithCodes:(NSArray<NSString *> *)codes;
105
+
106
+ /**
107
+ Subscribe for messages arriving with push notifications. @warning You need to unsubscribe by calling the removeObserver method, if you don't want to receive notifications
108
+
109
+ @param completion - return the collection of the InboxMessages.
110
+ */
111
+ + (id<NSObject>)addObserverForDidReceiveInPushNotificationCompletion:(void (^)(NSArray<NSObject<PWInboxMessageProtocol> *> *messagesAdded))completion;
112
+
113
+ /**
114
+ Subscribe for messages arriving when a message is deleted, added, or updated. @warning You need to unsubscribe by calling the removeObserver method, if you don't want to receive notifications
115
+
116
+ @param completion - return the collection of the InboxMessages.
117
+ */
118
+ + (id<NSObject>)addObserverForUpdateInboxMessagesCompletion:(void (^)(NSArray<NSObject<PWInboxMessageProtocol> *> *messagesDeleted,
119
+ NSArray<NSObject<PWInboxMessageProtocol> *> *messagesAdded,
120
+ NSArray<NSObject<PWInboxMessageProtocol> *> *messagesUpdated))completion;
121
+
122
+ /**
123
+ Subscribe for unread messages count changes. @warning You need to unsubscribe by calling the removeObserver method, if you don't want to receive notifications
124
+
125
+ @param block - return the count of unread messages.
126
+ */
127
+ + (id<NSObject>)addObserverForUnreadMessagesCountUsingBlock:(void (^)(NSUInteger count))block;
128
+
129
+ /**
130
+ Subscribe for messages with no action performed count changes. @warning You need to unsubscribe by calling the removeObserver method, if you don't want to receive notifications
131
+
132
+ @param block - return the count of unread messages.
133
+ */
134
+ + (id<NSObject>)addObserverForNoActionPerformedMessagesCountUsingBlock:(void (^)(NSUInteger count))block;
135
+
136
+ /**
137
+ Unsubscribes from notifications
138
+
139
+ @param observer - Unsubscribes observer
140
+ */
141
+ + (void)removeObserver:(id<NSObject>)observer;
142
+
143
+ /**
144
+ updates observers
145
+ */
146
+ + (void)updateInboxForNewUserId:(void (^)(NSUInteger messagesCount))completion;
147
+ @end
@@ -0,0 +1,26 @@
1
+ //
2
+ // PWInlineInAppView.h
3
+ // Pushwoosh SDK
4
+ // (c) Pushwoosh 2018
5
+ //
6
+
7
+ #import <UIKit/UIKit.h>
8
+
9
+ @class PWInlineInAppView;
10
+
11
+ @protocol PWInlineInAppViewDelegate <NSObject>
12
+
13
+ @optional
14
+ - (void)inlineInAppDidLoadInView:(PWInlineInAppView *)inAppView;
15
+ - (void)didCloseInlineInAppView:(PWInlineInAppView *)inAppView;
16
+ - (void)didChangeSizeOfInlineInAppView:(PWInlineInAppView *)inAppView;
17
+
18
+ @end
19
+
20
+ @interface PWInlineInAppView : UIView
21
+
22
+ @property (nonatomic) IBInspectable NSString *identifier;
23
+
24
+ @property (nonatomic, weak) id <PWInlineInAppViewDelegate> delegate;
25
+
26
+ @end
@@ -0,0 +1,23 @@
1
+ //
2
+ // PWLog.h
3
+ // Pushwoosh SDK
4
+ // (c) Pushwoosh 2016
5
+ //
6
+
7
+ #import <Foundation/Foundation.h>
8
+
9
+ typedef NSString *PWLogLevel NS_EXTENSIBLE_STRING_ENUM;
10
+
11
+ extern PWLogLevel const PWLogLevelNone;
12
+ extern PWLogLevel const PWLogLevelError;
13
+ extern PWLogLevel const PWLogLevelWarning;
14
+ extern PWLogLevel const PWLogLevelInfo;
15
+ extern PWLogLevel const PWLogLevelDebug;
16
+ extern PWLogLevel const PWLogLevelVerbose;
17
+
18
+ @interface PWLog : NSObject
19
+
20
+ + (void)setLogsHandler:(void(^)(PWLogLevel level, NSString *description))logsHandler;
21
+ + (void)removeLogsHandler;
22
+
23
+ @end