-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #357 from e-picsa/ft/show-prompt-of-update
Feat: show play update prompt
- Loading branch information
Showing
7 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { AppUpdate, AppUpdateAvailability, AppUpdateInfo } from '@capawesome/capacitor-app-update'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class AppUpdateService { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
constructor() {} | ||
|
||
/** Checks for app updates and starts a flexible update if allowed */ | ||
async checkForUpdates() { | ||
try { | ||
const appUpdateInfo: AppUpdateInfo = await AppUpdate.getAppUpdateInfo(); | ||
if ( | ||
appUpdateInfo.updateAvailability === AppUpdateAvailability.UPDATE_AVAILABLE && | ||
appUpdateInfo.flexibleUpdateAllowed | ||
) { | ||
await this.startFlexibleUpdate(); | ||
} | ||
} catch (error) { | ||
console.error('Error checking for updates:', error); | ||
} | ||
} | ||
|
||
/** Starts a flexible update process */ | ||
private async startFlexibleUpdate() { | ||
try { | ||
await AppUpdate.startFlexibleUpdate(); | ||
// Complete the update once it's downloaded | ||
await AppUpdate.completeFlexibleUpdate(); | ||
} catch (error) { | ||
console.error('Error during flexible update:', error); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// NOTE - to use these service must import PicsaNativeModule in app root with forRoot call | ||
|
||
export * from './app-update'; | ||
export * from './print'; | ||
export * from './storage-service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters