pushwoosh-react-native-plugin 6.1.50 → 6.1.51

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.js CHANGED
@@ -4,6 +4,22 @@ import { NativeModules } from 'react-native';
4
4
 
5
5
  const PushwooshModule = NativeModules.Pushwoosh;
6
6
 
7
+ //Constant: RichMediaStyle
8
+ //Rich Media presentation style constants.
9
+ //
10
+ //Values:
11
+ // MODAL - Rich Media displayed as modal dialog
12
+ // LEGACY - Rich Media displayed as full-screen activity
13
+ //
14
+ //Example:
15
+ //(start code)
16
+ // Pushwoosh.setRichMediaType(Pushwoosh.RichMediaStyle.MODAL);
17
+ //(end)
18
+ const RichMediaStyle = {
19
+ MODAL: 0,
20
+ LEGACY: 1
21
+ };
22
+
7
23
  //Class: PushNotification
8
24
  //Use `PushNotification` to register device for push notifications on Pushwoosh and customize notification appearance.
9
25
  //
@@ -621,11 +637,38 @@ class PushNotification {
621
637
  PushwooshModule.setLanguage(language);
622
638
  }
623
639
 
624
- // Enables Huawei push messaging
640
+ // Enables Huawei push messaging
625
641
  enableHuaweiPushNotifications() {
626
642
  PushwooshModule.enableHuaweiPushNotifications();
627
643
  }
628
644
 
645
+ // Sets the Rich Media presentation style.
646
+ //
647
+ // Parameters:
648
+ // "type" - Rich Media style (Pushwoosh.RichMediaStyle.MODAL or Pushwoosh.RichMediaStyle.LEGACY)
649
+ //
650
+ // Example:
651
+ // Pushwoosh.setRichMediaType(Pushwoosh.RichMediaStyle.MODAL);
652
+ setRichMediaType(type: number) {
653
+ PushwooshModule.setRichMediaType(type);
654
+ }
655
+
656
+ // Returns the current Rich Media presentation style.
657
+ //
658
+ // Parameters:
659
+ // "callback" - callback function that receives the current style (MODAL, LEGACY)
660
+ //
661
+ // Example:
662
+ // Pushwoosh.getRichMediaType((type) => {
663
+ // console.log("Rich Media Type: " + (type === Pushwoosh.RichMediaStyle.MODAL ? "MODAL" : "LEGACY"));
664
+ // });
665
+ getRichMediaType(callback: Function) {
666
+ PushwooshModule.getRichMediaType(callback);
667
+ }
668
+
629
669
  }
630
670
 
671
+ // Export RichMediaStyle constants
672
+ PushNotification.prototype.RichMediaStyle = RichMediaStyle;
673
+
631
674
  module.exports = new PushNotification();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushwoosh-react-native-plugin",
3
- "version": "6.1.50",
3
+ "version": "6.1.51",
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,13 +1,13 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = "pushwoosh-react-native-plugin"
3
- s.version = "6.1.50"
3
+ s.version = "6.1.51"
4
4
  s.summary = "React Native Pushwoosh Push Notifications module"
5
5
  s.requires_arc = true
6
6
  s.author = 'Pushwoosh'
7
7
  s.license = 'MIT'
8
8
  s.homepage = 'n/a'
9
9
  s.source = { :git => "https://github.com/Pushwoosh/pushwoosh-react-native-plugin.git" }
10
- s.source_files = 'src/ios/PushwooshPlugin/Pushwoosh.{h,m}', 'src/ios/PushwooshPlugin/PWEventDispatcher.{h,m}', 'src/ios/PushwooshPlugin/PWInlineInAppManager.{h,m}'
10
+ s.source_files = 'src/ios/PushwooshPlugin/Pushwoosh.{h,m}', 'src/ios/PushwooshPlugin/PWEventDispatcher.{h,m}'
11
11
  s.platform = :ios, "11.0"
12
12
  s.xcconfig = {
13
13
  "HEADER_SEARCH_PATHS" => "${PODS_ROOT}/Headers/Public/React"
@@ -1,14 +1,11 @@
1
1
  package com.pushwoosh.reactnativeplugin;
2
2
 
3
- import android.view.ViewManager;
4
-
5
3
  import com.facebook.react.ReactPackage;
6
4
  import com.facebook.react.bridge.JavaScriptModule;
7
5
  import com.facebook.react.bridge.NativeModule;
8
6
  import com.facebook.react.bridge.ReactApplicationContext;
9
7
 
10
8
  import java.util.ArrayList;
11
- import java.util.Arrays;
12
9
  import java.util.Collections;
13
10
  import java.util.List;
14
11
 
@@ -20,7 +17,7 @@ public class PushwooshPackage implements ReactPackage {
20
17
 
21
18
  @Override
22
19
  public List<com.facebook.react.uimanager.ViewManager> createViewManagers(ReactApplicationContext reactContext) {
23
- return Arrays.<com.facebook.react.uimanager.ViewManager>asList(new InlineInAppManager());
20
+ return Collections.emptyList();
24
21
  }
25
22
 
26
23
  @Override
@@ -43,6 +43,8 @@ import com.pushwoosh.notification.VibrateType;
43
43
  import com.pushwoosh.tags.TagsBundle;
44
44
  import com.pushwoosh.notification.LocalNotification;
45
45
  import com.pushwoosh.notification.LocalNotificationReceiver;
46
+ import com.pushwoosh.richmedia.RichMediaManager;
47
+ import com.pushwoosh.richmedia.RichMediaType;
46
48
 
47
49
  import org.json.JSONObject;
48
50
 
@@ -93,7 +95,6 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
93
95
  return "Pushwoosh";
94
96
  }
95
97
 
96
-
97
98
  @ReactMethod
98
99
  public void init(ReadableMap config, Callback success, Callback error) {
99
100
  String appId = config.getString("pw_appid");
@@ -550,6 +551,18 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
550
551
  Pushwoosh.getInstance().registerWhatsappNumber(phoneNumber);
551
552
  }
552
553
 
554
+ @ReactMethod
555
+ public void setRichMediaType(int type) {
556
+ RichMediaType richMediaType = type == 0 ? RichMediaType.MODAL : RichMediaType.DEFAULT;
557
+ RichMediaManager.setRichMediaType(richMediaType);
558
+ }
559
+
560
+ @ReactMethod
561
+ public void getRichMediaType(Callback callback) {
562
+ RichMediaType type = RichMediaManager.getRichMediaType();
563
+ callback.invoke(type.ordinal());
564
+ }
565
+
553
566
  ///
554
567
  /// LifecycleEventListener callbacks
555
568
  ///
@@ -12,16 +12,16 @@
12
12
 
13
13
  #if __has_include(<PushwooshFramework/PushNotificationManager.h>)
14
14
  #import <PushwooshFramework/PushNotificationManager.h>
15
- #import <PushwooshFramework/PWInAppManager.h>
16
- #import <PushwooshInboxUI/PushwooshInboxUI.h>
17
- #import <PushwooshFramework/PWInlineInAppView.h>
18
15
  #import <PushwooshFramework/PWInbox.h>
16
+ #import <PushwooshCore/PWInAppManager.h>
17
+ #import <PushwooshCore/PWMedia.h>
18
+ #import <PushwooshInboxUI/PushwooshInboxUI.h>
19
19
  #else
20
20
  #import "PushNotificationManager.h"
21
+ #import "PWInbox.h"
21
22
  #import "PWInAppManager.h"
23
+ #import "PWMedia.h"
22
24
  #import "PushwooshInboxUI.h"
23
- #import "PWInlineInAppView.h"
24
- #import "PWInbox.h"
25
25
  #endif
26
26
 
27
27
  @interface PushwooshPlugin: RCTEventEmitter<RCTBridgeModule, PushNotificationDelegate>
@@ -879,7 +879,21 @@ RCT_EXPORT_METHOD(registerSMSNumber:(NSString *)phoneNumber) {
879
879
  RCT_EXPORT_METHOD(registerWhatsappNumber:(NSString *)phoneNumber) {
880
880
  [[Pushwoosh sharedInstance] registerWhatsappNumber:phoneNumber];
881
881
  }
882
-
882
+
883
+ RCT_EXPORT_METHOD(setRichMediaType:(nonnull NSNumber *)type) {
884
+ PWRichMediaPresentationStyle style = [type integerValue] == 0
885
+ ? PWRichMediaPresentationStyleModal
886
+ : PWRichMediaPresentationStyleLegacy;
887
+ [Pushwoosh.media setRichMediaPresentationStyle:style];
888
+ }
889
+
890
+ RCT_EXPORT_METHOD(getRichMediaType:(RCTResponseSenderBlock)callback) {
891
+ PWRichMediaPresentationStyle style = [Pushwoosh.media richMediaPresentationStyle];
892
+ if (callback) {
893
+ callback(@[@(style)]);
894
+ }
895
+ }
896
+
883
897
  #pragma mark - PushNotificationDelegate
884
898
 
885
899
  - (void)onDidRegisterForRemoteNotificationsWithDeviceToken:(NSString *)token {
package/InlineInApp.js DELETED
@@ -1,71 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import {requireNativeComponent} from 'react-native';
4
-
5
- class InlineInAppView extends React.Component {
6
- _onLoaded = (event) => {
7
- if (!this.props.onLoaded) {
8
- return;
9
- }
10
-
11
- // process raw event...
12
- this.props.onLoaded(event.nativeEvent);
13
- }
14
-
15
- _onClosed = (event) => {
16
- if (!this.props.onClosed) {
17
- return;
18
- }
19
-
20
- // process raw event...
21
- this.props.onClosed(event.nativeEvent);
22
- }
23
-
24
- _onSizeChanged = (event) => {
25
- if (!this.props.onSizeChanged) {
26
- return;
27
- }
28
-
29
- // process raw event...
30
- this.props.onSizeChanged(event.nativeEvent);
31
- }
32
-
33
- render() {
34
- return (
35
- <PWInlineInAppView
36
- {...this.props}
37
- onLoaded = {this._onLoaded}
38
- onClosed = {this._onClosed}
39
- onSizeChanged = {this._onSizeChanged}
40
- />
41
- );
42
- }
43
- }
44
-
45
- InlineInAppView.propTypes = {
46
- /**
47
- * Value of the identifier property must be equal to the
48
- * identifier attribute value of the in-app message you've
49
- * created in Pushwoosh Control Panel
50
- */
51
- identifier: PropTypes.string,
52
- /**
53
- * This event is called to notify you that an inline in-app
54
- * was loaded and has been added to the view
55
- */
56
- onLoaded: PropTypes.func,
57
- /**
58
- * This event is called to notify you that an inline in-app
59
- * view has been closed by the user
60
- */
61
- onClosed: PropTypes.func,
62
- /**
63
- * This event is called to notify you that an inline in-app
64
- * view size has been changed
65
- */
66
- onSizeChanged: PropTypes.func,
67
- };
68
-
69
- var PWInlineInAppView = requireNativeComponent('PWInlineInAppView', InlineInAppView)
70
-
71
- export default InlineInAppView
@@ -1,48 +0,0 @@
1
- package com.pushwoosh.reactnativeplugin;
2
-
3
- import com.facebook.react.common.MapBuilder;
4
- import com.facebook.react.uimanager.SimpleViewManager;
5
- import com.facebook.react.uimanager.ThemedReactContext;
6
- import com.facebook.react.uimanager.annotations.ReactProp;
7
-
8
- import java.util.Map;
9
-
10
- public class InlineInAppManager extends SimpleViewManager<RCTInlineInAppView> {
11
- public static final String REACT_CLASS = "PWInlineInAppView";
12
-
13
- @Override
14
- public String getName() {
15
- return REACT_CLASS;
16
- }
17
-
18
- @Override
19
- public RCTInlineInAppView createViewInstance(ThemedReactContext context) {
20
- RCTInlineInAppView view = new RCTInlineInAppView(context);
21
- return view;
22
- }
23
-
24
- @ReactProp(name = "identifier")
25
- public void setIdentifier(final RCTInlineInAppView view, String identifier) {
26
- view.setIdentifier(identifier);
27
- }
28
-
29
- public Map getExportedCustomBubblingEventTypeConstants() {
30
- return MapBuilder.builder()
31
- .put(
32
- "onLoaded",
33
- MapBuilder.of(
34
- "phasedRegistrationNames",
35
- MapBuilder.of("bubbled", "onLoaded")))
36
- .put(
37
- "onClosed",
38
- MapBuilder.of(
39
- "phasedRegistrationNames",
40
- MapBuilder.of("bubbled", "onClosed")))
41
- .put(
42
- "onSizeChanged",
43
- MapBuilder.of(
44
- "phasedRegistrationNames",
45
- MapBuilder.of("bubbled", "onSizeChanged")))
46
- .build();
47
- }
48
- }
@@ -1,75 +0,0 @@
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
- }
@@ -1,17 +0,0 @@
1
- //
2
- // PWInlineInAppManager.h
3
- // pushwoosh-react-native-plugin
4
- //
5
- // Created by Fectum on 15/01/2020.
6
- //
7
-
8
- #import "RCTViewManager.h"
9
- #import "Pushwoosh.h"
10
-
11
- NS_ASSUME_NONNULL_BEGIN
12
-
13
- @interface PWInlineInAppManager : RCTViewManager <PWInlineInAppViewDelegate>
14
-
15
- @end
16
-
17
- NS_ASSUME_NONNULL_END
@@ -1,54 +0,0 @@
1
- //
2
- // PWInlineInAppManager.m
3
- // pushwoosh-react-native-plugin
4
- //
5
- // Created by Fectum on 15/01/2020.
6
- //
7
-
8
- #import "PWInlineInAppManager.h"
9
-
10
- @interface PWReactInlineInAppView: PWInlineInAppView
11
-
12
- @property (nonatomic) RCTBubblingEventBlock onLoaded;
13
- @property (nonatomic) RCTBubblingEventBlock onClosed;
14
- @property (nonatomic) RCTBubblingEventBlock onSizeChanged;
15
-
16
- @end
17
-
18
- @implementation PWReactInlineInAppView
19
- @end
20
-
21
- @implementation PWInlineInAppManager
22
-
23
- RCT_EXPORT_MODULE(PWInlineInAppView)
24
-
25
- - (UIView *)view {
26
- PWReactInlineInAppView *view = [PWReactInlineInAppView new];
27
- view.delegate = self;
28
- return view;
29
- }
30
-
31
- RCT_EXPORT_VIEW_PROPERTY(identifier, NSString)
32
- RCT_EXPORT_VIEW_PROPERTY(onLoaded, RCTBubblingEventBlock)
33
- RCT_EXPORT_VIEW_PROPERTY(onClosed, RCTBubblingEventBlock)
34
- RCT_EXPORT_VIEW_PROPERTY(onSizeChanged, RCTBubblingEventBlock)
35
-
36
- - (void)inlineInAppDidLoadInView:(PWReactInlineInAppView *)inAppView {
37
- if (inAppView.onLoaded) {
38
- inAppView.onLoaded(@{@"identifier": inAppView.identifier});
39
- }
40
- }
41
-
42
- - (void)didCloseInlineInAppView:(PWReactInlineInAppView *)inAppView {
43
- if (inAppView.onClosed) {
44
- inAppView.onClosed(@{@"identifier": inAppView.identifier});
45
- }
46
- }
47
-
48
- - (void)didChangeSizeOfInlineInAppView:(PWReactInlineInAppView *)inAppView {
49
- if (inAppView.onSizeChanged) {
50
- inAppView.onSizeChanged(@{@"width": @(inAppView.bounds.size.width), @"height": @(inAppView.bounds.size.height)});
51
- }
52
- }
53
-
54
- @end