forked from Ivasoft/mattermost-mobile
* Push notifications entry point * Process android notification natively only if RN is not initialized * Database changes to store local channel viewed_at * EphemeralStore wait until screen removed * Move schedule session notification to utility * Fix channel remote & local actions + added actions for markChannelAsViewed & fetchMyChannel * Add fetchMyTeam remote action * Add dismissAllModalsAndPopToScreen to navigation * Improve post list component & add app state to re-trigger queries * Improve WS implementation * Handle push notification events * Fix postsInChannel since handler * Handle in-app notifications * Post list to listen to column changes * Track selected bottom tab in ephemeral store * add useIsTablet hook * in-app notifications on tablets
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {NativeModules, PermissionsAndroid} from 'react-native';
|
|
|
|
const {NotificationPreferences} = NativeModules;
|
|
|
|
const defaultPreferences: NativeNotificationPreferences = {
|
|
sounds: [],
|
|
shouldBlink: false,
|
|
shouldVibrate: true,
|
|
};
|
|
|
|
export default {
|
|
getDeliveredNotifications: NotificationPreferences.getDeliveredNotifications,
|
|
getPreferences: async () => {
|
|
try {
|
|
const hasPermission = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE);
|
|
let granted;
|
|
if (!hasPermission) {
|
|
granted = await PermissionsAndroid.request(
|
|
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
|
|
);
|
|
}
|
|
|
|
if (hasPermission || granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
return await NotificationPreferences.getPreferences();
|
|
}
|
|
|
|
return defaultPreferences;
|
|
} catch (error) {
|
|
return defaultPreferences;
|
|
}
|
|
},
|
|
play: NotificationPreferences.previewSound,
|
|
removeDeliveredNotifications: NotificationPreferences.removeDeliveredNotifications,
|
|
setNotificationSound: NotificationPreferences.setNotificationSound,
|
|
setShouldBlink: NotificationPreferences.setShouldBlink,
|
|
setShouldVibrate: NotificationPreferences.setShouldVibrate,
|
|
} as NativeNotification;
|