Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if isConsented, don't re-prompt for optional permissions #1185

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.cordovabuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"cordova-plugin-app-version": "0.1.14",
"cordova-plugin-customurlscheme": "5.0.2",
"cordova-plugin-device": "2.1.0",
"cordova-plugin-em-datacollection": "git+https://github.com/e-mission/e-mission-data-collection.git#v1.9.3",
"cordova-plugin-em-datacollection": "git+https://github.com/e-mission/e-mission-data-collection.git#v1.9.4",
"cordova-plugin-em-opcodeauth": "git+https://github.com/e-mission/cordova-jwt-auth.git#v1.7.2",
"cordova-plugin-em-server-communication": "git+https://github.com/e-mission/cordova-server-communication.git#v1.2.7",
"cordova-plugin-em-serversync": "git+https://github.com/e-mission/cordova-server-sync.git#v1.3.3",
Expand Down
2 changes: 1 addition & 1 deletion www/js/onboarding/onboardingHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function getPendingOnboardingState(): Promise<OnboardingState> {
);
}

async function readConsented() {
export async function readConsented() {
return readConsentState().then(isConsented) as Promise<boolean>;
}

Expand Down
8 changes: 3 additions & 5 deletions www/js/usePermissionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { useTranslation } from 'react-i18next';
import { useAppTheme } from './appTheme';
import { logDebug, logWarn } from './plugin/logger';
import { AlertManager } from './components/AlertBar';
import { storageGet } from './plugin/storage';

const HAS_REQUESTED_NOTIFS_KEY = 'HasRequestedNotificationPermission';
import { readConsented } from './onboarding/onboardingHelper';

let DEVICE_PLATFORM: 'android' | 'ios';
let DEVICE_VERSION: number;
Expand Down Expand Up @@ -368,12 +366,12 @@ const usePermissionStatus = () => {
//load when ready
useEffect(() => {
if (appConfig && window['device']?.platform) {
storageGet(HAS_REQUESTED_NOTIFS_KEY).then((hasRequestedNotifs) => {
readConsented().then((isConsented) => {
DEVICE_PLATFORM = window['device'].platform.toLowerCase();
DEVICE_VERSION = window['device'].version.split('.')[0];
setupPermissionText();
logDebug('setting up permissions');
createChecklist(hasRequestedNotifs);
createChecklist(isConsented);
});
}
}, [appConfig]);
Expand Down
Loading