Skip to content

Commit 28da62f

Browse files
Merge pull request #3693 from dpalou/MOBILE-4270
Mobile 4270
2 parents becd020 + 9bb2956 commit 28da62f

File tree

7 files changed

+38
-10
lines changed

7 files changed

+38
-10
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"@moodlehq/cordova-plugin-qrscanner": "3.0.1-moodle.5",
8282
"@moodlehq/cordova-plugin-zip": "3.1.0-moodle.1",
8383
"@moodlehq/ionic-native-push": "5.36.0-moodle.2",
84-
"@moodlehq/phonegap-plugin-push": "4.0.0-moodle.3",
84+
"@moodlehq/phonegap-plugin-push": "4.0.0-moodle.4",
8585
"@ngx-translate/core": "13.0.0",
8686
"@ngx-translate/http-loader": "6.0.0",
8787
"@types/chart.js": "2.9.31",

scripts/langindex.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,6 +2349,7 @@
23492349
"core.settings.enablefirebaseanalyticsdescription": "local_moodlemobileapp",
23502350
"core.settings.enablerichtexteditor": "local_moodlemobileapp",
23512351
"core.settings.enablerichtexteditordescription": "local_moodlemobileapp",
2352+
"core.settings.encryptedpushsupported": "local_moodlemobileapp",
23522353
"core.settings.entriesincache": "local_moodlemobileapp",
23532354
"core.settings.estimatedfreespace": "local_moodlemobileapp",
23542355
"core.settings.filesystemroot": "local_moodlemobileapp",

src/core/features/pushnotifications/services/pushnotifications.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ export class CorePushNotificationsProvider {
726726
try {
727727

728728
const data = this.getRequiredRegisterData();
729-
data.publickey = await this.getPublicKey(site);
729+
data.publickey = await this.getPublicKeyForSite(site);
730730

731731
const neededActions = await this.getRegisterDeviceActions(data, site, forceUnregister);
732732

@@ -780,11 +780,24 @@ export class CorePushNotificationsProvider {
780780
* @param site Site to register
781781
* @returns Public key, undefined if the site or the device doesn't support encryption.
782782
*/
783-
protected async getPublicKey(site: CoreSite): Promise<string | undefined> {
783+
protected async getPublicKeyForSite(site: CoreSite): Promise<string | undefined> {
784784
if (!site.wsAvailable('core_user_update_user_device_public_key')) {
785785
return;
786786
}
787787

788+
return await this.getPublicKey();
789+
}
790+
791+
/**
792+
* Get the device public key.
793+
*
794+
* @returns Public key, undefined if the device doesn't support encryption.
795+
*/
796+
async getPublicKey(): Promise<string | undefined> {
797+
if (!CorePlatform.isMobile()) {
798+
return;
799+
}
800+
788801
const publicKey = await Push.getPublicKey();
789802

790803
return publicKey ?? undefined;

src/core/features/settings/lang.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"enablefirebaseanalyticsdescription": "If enabled, the app will collect anonymous data usage.",
3838
"enablerichtexteditor": "Enable text editor",
3939
"enablerichtexteditordescription": "If enabled, a text editor will be available when entering content.",
40+
"encryptedpushsupported": "Encrypted push notifications supported",
4041
"entriesincache": "{{$a}} entries in cache",
4142
"estimatedfreespace": "Estimated free space",
4243
"filesystemroot": "File system root",

src/core/features/settings/pages/deviceinfo/deviceinfo.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ <h1>
148148
<p>{{ deviceInfo.pushId }}</p>
149149
</ion-label>
150150
</ion-item>
151+
<ion-item *ngIf="deviceInfo.pushId" (longPress)="copyItemInfo($event)">
152+
<ion-label class="ion-text-wrap">
153+
<p class="item-heading">{{ 'core.settings.encryptedpushsupported' | translate }}</p>
154+
<p *ngIf="!deviceInfo.encryptedPushSupported">{{ 'core.no' | translate }}</p>
155+
<p *ngIf="deviceInfo.encryptedPushSupported">{{ 'core.yes' | translate }}</p>
156+
</ion-label>
157+
</ion-item>
151158
<ion-item (longPress)="copyItemInfo($event)">
152159
<ion-label class="ion-text-wrap">
153160
<p class="item-heading">{{ 'core.settings.localnotifavailable' | translate }}</p>

src/core/features/settings/pages/deviceinfo/deviceinfo.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ interface CoreSettingsDeviceInfo {
5858
uuid?: string;
5959
pushId?: string;
6060
localNotifAvailable: string;
61+
encryptedPushSupported?: boolean;
6162
}
6263

6364
/**
@@ -210,6 +211,11 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
210211
const showDevOptionsOnConfig = await CoreConfig.get('showDevOptions', 0);
211212
this.devOptionsForced = CoreConstants.BUILD.isDevelopment || CoreConstants.BUILD.isTesting;
212213
this.showDevOptions = this.devOptionsForced || showDevOptionsOnConfig == 1;
214+
215+
const publicKey = this.deviceInfo.pushId ?
216+
await CoreUtils.ignoreErrors(CorePushNotifications.getPublicKey()) :
217+
undefined;
218+
this.deviceInfo.encryptedPushSupported = publicKey !== undefined;
213219
}
214220

215221
/**

0 commit comments

Comments
 (0)