1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Trying RN notification

This commit is contained in:
Laurent Cozic 2017-11-24 20:14:56 +00:00
parent 60d2b0c763
commit 8ccf2ec521
7 changed files with 100 additions and 33 deletions

View File

@ -137,6 +137,7 @@ android {
} }
dependencies { dependencies {
compile project(':react-native-push-notification')
compile project(':react-native-fs') compile project(':react-native-fs')
compile project(':react-native-image-picker') compile project(':react-native-image-picker')
compile project(':react-native-vector-icons') compile project(':react-native-vector-icons')

View File

@ -1,37 +1,83 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="net.cozic.joplin" package="net.cozic.joplin"
android:versionCode="2" android:versionCode="2"
android:versionName="0.8.0"> android:versionName="0.8.0">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/> <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>
<uses-sdk <!-- ==================================== -->
android:minSdkVersion="16" <!-- START react-native-push-notification -->
android:targetSdkVersion="22" /> <!-- ==================================== -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- ================================== -->
<!-- END react-native-push-notification -->
<!-- ================================== -->
<application <uses-sdk
android:name=".MainApplication" android:minSdkVersion="16"
android:allowBackup="true" android:targetSdkVersion="22" />
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" <application
android:theme="@style/AppTheme"> android:name=".MainApplication"
<activity android:allowBackup="true"
android:name=".MainActivity" android:label="@string/app_name"
android:label="@string/app_name" android:icon="@mipmap/ic_launcher"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:theme="@style/AppTheme">
android:windowSoftInputMode="adjustResize"
android:launchMode="singleInstance"> <!-- ==================================== -->
<intent-filter> <!-- START react-native-push-notification -->
<action android:name="android.intent.action.MAIN" /> <!-- ==================================== -->
<category android:name="android.intent.category.LAUNCHER" /> <receiver
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/> android:name="com.google.android.gms.gcm.GcmReceiver"
</intent-filter> android:exported="true"
</activity> android:permission="com.google.android.c2dm.permission.SEND" >
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> <intent-filter>
</application> <action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<!-- ================================== -->
<!-- END react-native-push-notification -->
<!-- ================================== -->
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest> </manifest>

View File

@ -3,6 +3,7 @@ package net.cozic.joplin;
import android.app.Application; import android.app.Application;
import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.imagepicker.ImagePickerPackage; import com.imagepicker.ImagePickerPackage;
import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage; import com.facebook.react.ReactPackage;
@ -31,6 +32,7 @@ public class MainApplication extends Application implements ReactApplication {
return Arrays.<ReactPackage>asList( return Arrays.<ReactPackage>asList(
new ImageResizerPackage(), new ImageResizerPackage(),
new MainReactPackage(), new MainReactPackage(),
new ReactNativePushNotificationPackage(),
new ImagePickerPackage(), new ImagePickerPackage(),
new ReactNativeDocumentPicker(), new ReactNativeDocumentPicker(),
new RNFetchBlobPackage(), new RNFetchBlobPackage(),

View File

@ -1,4 +1,6 @@
rootProject.name = 'Joplin' rootProject.name = 'Joplin'
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android')
include ':react-native-fs' include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android') project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
include ':react-native-image-picker' include ':react-native-image-picker'

View File

@ -4705,6 +4705,11 @@
"resolved": "https://registry.npmjs.org/react-native-popup-menu/-/react-native-popup-menu-0.8.3.tgz", "resolved": "https://registry.npmjs.org/react-native-popup-menu/-/react-native-popup-menu-0.8.3.tgz",
"integrity": "sha1-HbsLT4iclBC2myKKidV7Vq6lzC4=" "integrity": "sha1-HbsLT4iclBC2myKKidV7Vq6lzC4="
}, },
"react-native-push-notification": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/react-native-push-notification/-/react-native-push-notification-3.0.1.tgz",
"integrity": "sha1-DiPbMC0Du0o/KNwHLcryqaEXjtg="
},
"react-native-side-menu": { "react-native-side-menu": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/react-native-side-menu/-/react-native-side-menu-1.1.3.tgz", "resolved": "https://registry.npmjs.org/react-native-side-menu/-/react-native-side-menu-1.1.3.tgz",

View File

@ -29,6 +29,7 @@
"react-native-material-dropdown": "^0.5.2", "react-native-material-dropdown": "^0.5.2",
"react-native-popup-dialog": "^0.9.35", "react-native-popup-dialog": "^0.9.35",
"react-native-popup-menu": "^0.8.3", "react-native-popup-menu": "^0.8.3",
"react-native-push-notification": "^3.0.1",
"react-native-side-menu": "^1.1.3", "react-native-side-menu": "^1.1.3",
"react-native-sqlite-storage": "3.3.*", "react-native-sqlite-storage": "3.3.*",
"react-native-vector-icons": "^4.4.2", "react-native-vector-icons": "^4.4.2",

View File

@ -37,10 +37,11 @@ const { _, setLocale, closestSupportedLocale, defaultLocale } = require('lib/loc
const RNFetchBlob = require('react-native-fetch-blob').default; const RNFetchBlob = require('react-native-fetch-blob').default;
const { PoorManIntervals } = require('lib/poor-man-intervals.js'); const { PoorManIntervals } = require('lib/poor-man-intervals.js');
const { reducer, defaultState } = require('lib/reducer.js'); const { reducer, defaultState } = require('lib/reducer.js');
const PushNotification = require('react-native-push-notification');
const SyncTargetRegistry = require('lib/SyncTargetRegistry.js'); const SyncTargetRegistry = require('lib/SyncTargetRegistry.js');
const SyncTargetOneDrive = require('lib/SyncTargetOneDrive.js'); const SyncTargetOneDrive = require('lib/SyncTargetOneDrive.js');
const SyncTargetOneDriveDev = require('lib/SyncTargetOneDriveDev.js'); const SyncTargetOneDriveDev = require('lib/SyncTargetOneDriveDev.js');
SyncTargetRegistry.addClass(SyncTargetOneDrive); SyncTargetRegistry.addClass(SyncTargetOneDrive);
SyncTargetRegistry.addClass(SyncTargetOneDriveDev); SyncTargetRegistry.addClass(SyncTargetOneDriveDev);
@ -364,6 +365,15 @@ async function initialize(dispatch, backButtonHandler) {
reg.scheduleSync(); reg.scheduleSync();
} }
PushNotification.localNotificationSchedule({
message: "My Notification Message", // (required)
date: new Date(Date.now() + (10 * 1000)) // in 60 secs
});
reg.logger().info('Application initialized'); reg.logger().info('Application initialized');
} }