Skip to content

Commit

Permalink
Merge pull request #1185 from JGreenlee/optional-permissions-isconsented
Browse files Browse the repository at this point in the history
if isConsented, don't re-prompt for optional permissions
  • Loading branch information
shankari authored Oct 9, 2024
2 parents 655f843 + c9efeb4 commit ab90f8a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
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

0 comments on commit ab90f8a

Please sign in to comment.