Mobile: Resolves #8789: Fix older Android versions unable to set alarms (#8837)

release-2.12-mobile
Henry Heino 2023-09-11 12:45:32 -07:00 committed by GitHub
parent 78ffc0bc23
commit a07985da98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -7,7 +7,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.POST_NOTIFICATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

View File

@ -10,7 +10,8 @@ import { ChangeEvent, UndoRedoDepthChangeEvent } from '../NoteEditor/types';
const FileViewer = require('react-native-file-viewer').default;
const React = require('react');
const { Platform, Keyboard, View, TextInput, StyleSheet, Linking, Image, Share, PermissionsAndroid } = require('react-native');
const { Keyboard, View, TextInput, StyleSheet, Linking, Image, Share } = require('react-native');
import { Platform, PermissionsAndroid } from 'react-native';
const { connect } = require('react-redux');
// const { MarkdownEditor } = require('@joplin/lib/../MarkdownEditor/index.js');
import Note from '@joplin/lib/models/Note';
@ -807,8 +808,12 @@ class NoteScreenComponent extends BaseScreenComponent {
public async onAlarmDialogAccept(date: Date) {
const response = await checkPermissions(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
if (response !== PermissionsAndroid.RESULTS.GRANTED) {
logger.warn('POST_NOTIFICATION permission was not granted');
// The POST_NOTIFICATIONS permission isn't supported on Android API < 33.
// (If unsupported, returns NEVER_ASK_AGAIN).
// On earlier releases, notifications should work without this permission.
if (response === PermissionsAndroid.RESULTS.DENIED) {
logger.warn('POST_NOTIFICATIONS permission was not granted');
return;
}