Skip to content

Commit

Permalink
force native and notification info instead of warning
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelsc committed Oct 19, 2023
1 parent 7d072f0 commit 0e99a4c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/app/pages/dev/dev.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
<ion-label>Set "Last Closed" to 0 for all clients</ion-label>
</ion-item>

<ion-item lines="none">
<ion-icon slot="start" name="bug-outline"></ion-icon>
<ion-toggle
id="nativeRequests"
[(ngModel)]="forceNativeRequests"
(ionChange)="changeForceNativeRequests()"
labelPlacement="start"
justify="space-between"
>Force All Native POST</ion-toggle
>
</ion-item>

<ion-item lines="none">
<ion-icon class="opacity-icon" slot="start" name="bug-outline"></ion-icon>
<ion-select label="Override Premium" value="" [(ngModel)]="packageOverride" (ionChange)="changePackage()" interface="popover">
Expand Down
10 changes: 10 additions & 0 deletions src/app/pages/dev/dev.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class DevPage extends Tab3Page implements OnInit {
packageOverride = 'default'
firebaseToken = ''
notificationConsent = false
forceNativeRequests = false

ngOnInit() {
this.notificationBase.disableToggleLock()
Expand All @@ -27,6 +28,7 @@ export class DevPage extends Tab3Page implements OnInit {
})

this.firebaseUtils.hasNotificationConsent().then((result) => (this.notificationConsent = result))
this.storage.getBooleanSetting('force_native_requests', false).then((result) => (this.forceNativeRequests = result))
}

// --- Development methods ---
Expand Down Expand Up @@ -106,6 +108,14 @@ export class DevPage extends Tab3Page implements OnInit {
})
}

changeForceNativeRequests() {
this.storage.setBooleanSetting('force_native_requests', this.forceNativeRequests)
console.log('forceNative changed to ' + this.forceNativeRequests)
this.alerts.confirmDialog('Restart', 'Requires restart to take affect, restart?', 'OK', () => {
this.restartApp()
})
}

restartApp() {
this.merchant.restartApp()
}
Expand Down
1 change: 0 additions & 1 deletion src/app/services/alert.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import { Injectable } from '@angular/core'
import { AlertController, LoadingController } from '@ionic/angular'

export const SETTINGS_PAGE = 100
export const VALIDATORUTILS = 140
export const PURCHASEUTILS = 150

Expand Down
4 changes: 4 additions & 0 deletions src/app/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export class ApiService extends CacheModule {
this.lastCacheInvalidate = Date.now()
//this.registerLogMiddleware()
this.updateNetworkConfig()
this.storage.getBooleanSetting('force_native_requests', false).then((result) => {
this.forceNativeAll = result
console.log('forcing native requests')
})
//this.isIOS15().then((result) => { this.forceNativeAll = result })
}

Expand Down
16 changes: 7 additions & 9 deletions src/app/tab-preferences/notification-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Platform } from '@ionic/angular'
import { ApiService } from 'src/app/services/api.service'
import { CPU_THRESHOLD, HDD_THRESHOLD, RAM_THRESHOLD, SETTING_NOTIFY, StorageService } from 'src/app/services/storage.service'
import { GetMobileSettingsRequest, MobileSettingsResponse, NotificationGetRequest } from '../requests/requests'
import { AlertService, SETTINGS_PAGE } from '../services/alert.service'
import { AlertService } from '../services/alert.service'
import { SyncService } from '../services/sync.service'
import ClientUpdateUtils, { Clients } from '../utils/ClientUpdateUtils'
import FirebaseUtils from '../utils/FirebaseUtils'
Expand Down Expand Up @@ -80,13 +80,6 @@ export class NotificationBase implements OnInit {
if (this.platform.is('android')) {
const hasToken = await this.firebaseUtils.hasNotificationToken()
if (!hasToken) {
this.alerts.showError(
'Play Service',
'We could not enable notifications for your device which might be due to missing Google Play Services. Please note that notifications do not work without Google Play Services.',
SETTINGS_PAGE + 2
)
this.notify = false

return false
}
}
Expand Down Expand Up @@ -193,7 +186,12 @@ export class NotificationBase implements OnInit {
}

async notifyToggle() {
if (!(await this.isSupportedOnAndroid())) return
if (!(await this.isSupportedOnAndroid())) {
this.alerts.showInfo(
'Play Service',
'Your device can not receive push notifications. Please note that notifications do not work without Google Play Services. As an alternative you can configure webhook notifications on the beaconcha.in website, otherwise changing these settings will have no effect.'
)
}

if (this.platform.is('ios') && (await this.firebaseUtils.hasSeenConsentScreenAndNotConsented())) {
this.notify = false
Expand Down

0 comments on commit 0e99a4c

Please sign in to comment.