diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 03def83..8cb8729 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -7,6 +7,9 @@ + + + @@ -22,44 +25,34 @@ - - - - - - - - - + android:icon="@mipmap/ic_launcher" + android:roundIcon="@mipmap/ic_launcher_round" + android:allowBackup="false" + android:theme="@style/AppTheme"> - - - + + + - - - + + + @@ -67,12 +60,5 @@ - - - - - diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index caab5fc..3534041 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -14,4 +14,5 @@ #A5A5A5 #F38337 #3A2671 + #69CBC1 \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 0db32f7..1b0aed6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -46,12 +46,9 @@ allprojects { } ext { - googlePlayServicesVersion = "+" // default: "+" - firebaseMessagingVersion = "21.1.0" // default: "+" - buildToolsVersion = "30.0.2" minSdkVersion = 23 compileSdkVersion = 30 targetSdkVersion = 30 - ndkVersion = "21.4.7075529" + ndkVersion = "21.4.7075529" } diff --git a/lib/notifications.js b/lib/notifications.js index 31778ad..f376784 100644 --- a/lib/notifications.js +++ b/lib/notifications.js @@ -1,8 +1,9 @@ +import { Platform } from 'react-native' import { tempReminderObservable, periodReminderObservable, } from '../local-storage' -import Notification from 'react-native-push-notification' +import * as PN from 'react-native-push-notification' import Moment from 'moment' import { LocalDate } from '@js-joda/core' @@ -12,7 +13,15 @@ import cycleModule from './cycle' import nothingChanged from '../db/db-unchanged' export default function setupNotifications(navigate, setDate) { - Notification.configure({ + const PushNotification = Platform.OS === 'ios' ? PN : PN.default + + PushNotification.createChannel({ + channelId: 'drip-channel-id', // (required) + channelName: 'drip reminder', // (required) + playSound: false, // (optional) default: true + }) + + PushNotification.configure({ onNotification: (notification) => { // https://github.com/zo0r/react-native-push-notification/issues/966#issuecomment-479069106 if (notification.data?.id === '1' || notification.id === '1') { @@ -26,7 +35,7 @@ export default function setupNotifications(navigate, setDate) { }) tempReminderObservable((reminder) => { - Notification.cancelLocalNotifications({ id: '1' }) + PushNotification.cancelLocalNotification({ id: '1' }) if (reminder.enabled) { const [hours, minutes] = reminder.time.split(':') let target = new Moment() @@ -38,31 +47,33 @@ export default function setupNotifications(navigate, setDate) { target = target.add(1, 'd') } - Notification.localNotificationSchedule({ + PushNotification.localNotificationSchedule({ id: '1', userInfo: { id: '1' }, message: labels.tempReminder.notification, date: target.toDate(), vibrate: false, repeatType: 'day', + channelId: 'drip-channel-id', }) } }, false) periodReminderObservable((reminder) => { - Notification.cancelLocalNotifications({ id: '2' }) + PushNotification.cancelLocalNotification({ id: '2' }) if (reminder.enabled) setupPeriodReminder() }, false) getBleedingDaysSortedByDate().addListener((_, changes) => { // the listener fires on setup, so we check if there were actually any changes if (nothingChanged(changes)) return - Notification.cancelLocalNotifications({ id: '2' }) + PushNotification.cancelLocalNotification({ id: '2' }) if (periodReminderObservable.value.enabled) setupPeriodReminder() }) } function setupPeriodReminder() { + const PushNotification = Platform.OS === 'ios' ? PN : PN.default const bleedingPrediction = cycleModule().getPredictedMenses() if (bleedingPrediction.length > 0) { const predictedBleedingStart = Moment( @@ -80,12 +91,13 @@ function setupPeriodReminder() { // period is likely to start in 3 to 3 + (length of prediction - 1) days const daysToEndOfPrediction = bleedingPrediction[0].length + 2 - Notification.localNotificationSchedule({ + PushNotification.localNotificationSchedule({ id: '2', userInfo: { id: '2' }, message: labels.periodReminder.notification(daysToEndOfPrediction), date: reminderDate.toDate(), vibrate: false, + channelId: 'drip-channel-id', }) } } diff --git a/package.json b/package.json index 5956dcd..e2ba014 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@react-native-async-storage/async-storage": "^1.17.9", "@react-native-community/art": "^1.2.0", "@react-native-community/datetimepicker": "^6.3.1", - "@react-native-community/push-notification-ios": "^1.8.0", + "@react-native-community/push-notification-ios": "^1.11.0", "csvtojson": "^2.0.8", "i18next": "^22.0.2", "jshashes": "^1.0.8", @@ -49,7 +49,7 @@ "react-native-document-picker": "^8.1.1", "react-native-fs": "^2.20.0", "react-native-modal-datetime-picker": "14.0.0", - "react-native-push-notification": "3.2.1", + "react-native-push-notification": "github:bl00dymarie/react-native-push-notification", "react-native-share": "^7.9.0", "react-native-simple-toast": "^1.1.3", "react-native-size-matters": "^0.4.0",