diff --git a/example/android/myapplication/build.gradle b/example/android/myapplication/build.gradle index 5c8cbee486408a9ec90b9d1cca89dd9220112e39..2adc9ac534174701de6b4010d2e33c4eea8e810f 100644 --- a/example/android/myapplication/build.gradle +++ b/example/android/myapplication/build.gradle @@ -13,10 +13,9 @@ apply from: "../../../node_modules/react-native/react.gradle" android { compileSdkVersion 28 buildToolsVersion "28.0.3" - defaultConfig { applicationId "com.wix.reactnativenotifications.app" - minSdkVersion 19 + minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" diff --git a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainActivity.java b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainActivity.java index 0aa9149123fec5ea3a43331ce2a660b50046984c..30fedc6f2067447ea247a0871cf99b92736c7226 100644 --- a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainActivity.java +++ b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainActivity.java @@ -1,40 +1,18 @@ package com.wix.reactnativenotifications.app; -import android.os.Build; import android.os.Bundle; -import android.view.ViewGroup; -import android.widget.Toolbar; - import com.facebook.react.ReactActivity; -import com.facebook.react.ReactRootView; -import static android.os.Build.VERSION.SDK_INT; public class MainActivity extends ReactActivity { - private ReactRootView mReactRootView; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - ViewGroup layout; - if (SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - layout = (ViewGroup) getLayoutInflater().inflate(R.layout.activity_main, null); - Toolbar toolbar = layout.findViewById(R.id.toolbar); - setActionBar(toolbar); - } else { - layout = (ViewGroup) getLayoutInflater().inflate(R.layout.activity_main_prelollipop, null); - } - mReactRootView = new ReactRootView(this); - layout.addView(mReactRootView); - - setContentView(layout); - - startReactApplication(); } - private void startReactApplication() { - mReactRootView.startReactApplication(getReactInstanceManager(), "NotificationsExampleApp", null); + @Override + protected String getMainComponentName() { + return "NotificationsExampleApp"; } } diff --git a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainApplication.java b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainApplication.java index 87b0d3a6ea174849a221b7e24bab964c1652eb91..24c9cbce864af3ea4effa4830539ce9fba38a810 100644 --- a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainApplication.java +++ b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainApplication.java @@ -24,7 +24,12 @@ public class MainApplication extends Application implements ReactApplication { return Arrays.asList( new MainReactPackage(), new RNNotificationsPackage(MainApplication.this) - ); + ); + } + + @Override + protected String getJSMainModuleName() { + return "index"; } }; diff --git a/example/index.js b/example/index.js index f047e961d1d01f0a1db39e7078cbcc43211211d5..c30bce596d842c0730572c1aa0d2163dd2e7c94f 100644 --- a/example/index.js +++ b/example/index.js @@ -6,7 +6,7 @@ import { Button } from 'react-native'; import React, {Component} from 'react'; -import { Notifications } from 'react-native-notifications'; +import {Notifications} from 'react-native-notifications'; class NotificationsExampleApp extends Component { constructor() { @@ -22,7 +22,7 @@ class NotificationsExampleApp extends Component { registerNotificationEvents() { Notifications.events().registerNotificationReceived((notification, completion) => { this.setState({ - notifications: [...this.state.notifications, notification.link] + notifications: [...this.state.notifications, notification] }); completion({alert: true, sound: false, badge: false}); @@ -30,15 +30,21 @@ class NotificationsExampleApp extends Component { Notifications.events().registerRemoteNotificationOpened((notification, completion) => { this.setState({ - notifications: [...this.state.notifications, `Notification Clicked: ${notification.link}`] + notifications: [...this.state.notifications, notification] }); - + completion(); }); } renderNotification(notification) { - return {`${notification}`}; + return ( + + {`Title: ${notification.title}`} + {`Body: ${notification.body}`} + {`Extra Link Param: ${notification.data.link}`} + + ); } requestPermissions() { @@ -51,7 +57,7 @@ class NotificationsExampleApp extends Component { title: String.fromCodePoint(0x1F44D), identifier: 'UPVOTE_ACTION' }; - + const replyAction = { activationMode: 'background', title: 'Reply', @@ -62,7 +68,7 @@ class NotificationsExampleApp extends Component { }, identifier: 'REPLY_ACTION' }; - + const category = { identifier: 'SOME_CATEGORY', actions: [upvoteAction, replyAction] @@ -88,13 +94,10 @@ class NotificationsExampleApp extends Component { async componentDidMount() { const initialNotification = await Notifications.getInitialNotification(); if (initialNotification) { - this.setState({notifications: [initialNotification.link, ...this.state.notifications]}); + this.setState({notifications: [initialNotification, ...this.state.notifications]}); } } - componentWillUnmount() { - } - render() { const notifications = this.state.notifications.map((notification, idx) => ( @@ -105,9 +108,9 @@ class NotificationsExampleApp extends Component { return ( -