From 41f1cb9bd3e19ca856b4737d6edf2928565db22c Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 30 Oct 2024 10:24:06 -0700 Subject: [PATCH 1/8] Add intent-filter and initialize deep linking in Capacitor --- .../android/app/src/main/AndroidManifest.xml | 32 ++--- .../src/main/angular/src/app/app.component.ts | 112 +++++++++++------- 2 files changed, 77 insertions(+), 67 deletions(-) diff --git a/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml b/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml index d2bf96d2b0..81a6563b48 100644 --- a/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml +++ b/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml @@ -1,31 +1,21 @@ - - - + + + + + + + + + - + diff --git a/client/wfnews-war/src/main/angular/src/app/app.component.ts b/client/wfnews-war/src/main/angular/src/app/app.component.ts index 74dad016d9..392bd26704 100644 --- a/client/wfnews-war/src/main/angular/src/app/app.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/app.component.ts @@ -36,6 +36,7 @@ import { LocationNotification, } from '@app/services/capacitor-service'; import { CommonUtilityService } from '@app/services/common-utility.service'; +import { App, URLOpenListenerEvent } from '@capacitor/app'; export const ICON = { ADVISORIES: 'advisories', @@ -170,6 +171,7 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit { ngOnInit() { if (this.isMobileView()) { + this.initializeDeepLinks(); if (typeof (window.screen.orientation as any).lock === 'function') { const lock = (window.screen.orientation as any).lock('portrait'); (lock as Promise) @@ -269,6 +271,24 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit { } } + initializeDeepLinks() { + App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => { + this.zone.run(() => { + console.log('Deep link URL: ' + event.url); + const domain = 'bcwildfireservices.com'; + + const pathArray = event.url.split(domain); + // The pathArray is now like ['bcwildfireservices.com', '/map?longitude=-124.62025&latitude=53.231&activeWildfires=true'] + + // Get the last element with pop() + const appPath = pathArray.pop(); + if (appPath) { + this.router.navigateByUrl(appPath); + } + }); + }); + } + isIncidentsPage() { return ( window.location.pathname === '/incidents' || @@ -370,52 +390,52 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit { initFooterMenu() { this.footerMenu = (this.applicationConfig.device == 'desktop' ? [ - new RouterLink( - 'Home', - 'https://www2.gov.bc.ca/gov/content/home', - 'home', - 'expanded', - this.router, - ), - new RouterLink( - 'Disclaimer', - 'https://www2.gov.bc.ca/gov/content?id=DE91907CDB3E4B5EB2F0363569079B85', - 'home', - 'expanded', - this.router, - ), - new RouterLink( - 'Privacy', - 'https://www2.gov.bc.ca/gov/content/home/privacy', - 'home', - 'expanded', - this.router, - ), - new RouterLink( - 'Accessibility', - 'https://www2.gov.bc.ca/gov/content/home/accessible-government', - 'home', - 'expanded', - this.router, - ), - new RouterLink( - 'Copyright', - 'https://www2.gov.bc.ca/gov/content/home/copyright', - 'home', - 'expanded', - this.router, - ), - new RouterLink( - 'Contact Us', - 'https://www2.gov.bc.ca/gov/content/home/get-help-with-government-services', - 'home', - 'expanded', - this.router, - ), - ] + new RouterLink( + 'Home', + 'https://www2.gov.bc.ca/gov/content/home', + 'home', + 'expanded', + this.router, + ), + new RouterLink( + 'Disclaimer', + 'https://www2.gov.bc.ca/gov/content?id=DE91907CDB3E4B5EB2F0363569079B85', + 'home', + 'expanded', + this.router, + ), + new RouterLink( + 'Privacy', + 'https://www2.gov.bc.ca/gov/content/home/privacy', + 'home', + 'expanded', + this.router, + ), + new RouterLink( + 'Accessibility', + 'https://www2.gov.bc.ca/gov/content/home/accessible-government', + 'home', + 'expanded', + this.router, + ), + new RouterLink( + 'Copyright', + 'https://www2.gov.bc.ca/gov/content/home/copyright', + 'home', + 'expanded', + this.router, + ), + new RouterLink( + 'Contact Us', + 'https://www2.gov.bc.ca/gov/content/home/get-help-with-government-services', + 'home', + 'expanded', + this.router, + ), + ] : [ - new RouterLink('Home', '/', 'home', 'hidden', this.router), - ]) as unknown as WfMenuItems; + new RouterLink('Home', '/', 'home', 'hidden', this.router), + ]) as unknown as WfMenuItems; } ngAfterViewInit() { @@ -956,7 +976,7 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit { } } - private updateMapSize = function() { + private updateMapSize = function () { this.storeViewportSize(); }; } From d8cfddefa27f82b4c16557d0afbb800dd0b38571 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 30 Oct 2024 13:35:40 -0700 Subject: [PATCH 2/8] Complete android config --- client/wfnews-war/src/main/angular/angular.json | 5 +++++ .../main/angular/src/.well-known/assetlinks.json | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 client/wfnews-war/src/main/angular/src/.well-known/assetlinks.json diff --git a/client/wfnews-war/src/main/angular/angular.json b/client/wfnews-war/src/main/angular/angular.json index 29ef98a5cd..522c4c152c 100644 --- a/client/wfnews-war/src/main/angular/angular.json +++ b/client/wfnews-war/src/main/angular/angular.json @@ -63,6 +63,11 @@ "glob": "bc-sans/**/*", "input": "node_modules/@wf1/wfcc-application-ui", "output": "assets" + }, + { + "glob": "**/*", + "input": "src/.well-known", + "output": ".well-known/" } ], "styles": [ diff --git a/client/wfnews-war/src/main/angular/src/.well-known/assetlinks.json b/client/wfnews-war/src/main/angular/src/.well-known/assetlinks.json new file mode 100644 index 0000000000..421a52ba44 --- /dev/null +++ b/client/wfnews-war/src/main/angular/src/.well-known/assetlinks.json @@ -0,0 +1,14 @@ +[ + { + "relation": [ + "delegate_permission/common.handle_all_urls" + ], + "target": { + "namespace": "android_app", + "package_name": "ca.bc.gov.WildfireInformation", + "sha256_cert_fingerprints": [ + "46:C7:E0:F6:C1:DF:BA:D8:93:E8:E7:09:A7:B6:D1:5D:ED:01:D0:DA:32:E7:2A:58:1B:14:E4:5F:23:57:A2:94" + ] + } + } +] \ No newline at end of file From 3e506c26a11df2784a3c1ae463b770d56342ab70 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 30 Oct 2024 13:51:41 -0700 Subject: [PATCH 3/8] Update android:host path and add association file for iOS --- .../android/app/src/main/AndroidManifest.xml | 2 +- .../src/.well-known/apple-app-site-association | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 client/wfnews-war/src/main/angular/src/.well-known/apple-app-site-association diff --git a/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml b/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml index 81a6563b48..c93d2d7037 100644 --- a/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml +++ b/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml @@ -11,7 +11,7 @@ - + diff --git a/client/wfnews-war/src/main/angular/src/.well-known/apple-app-site-association b/client/wfnews-war/src/main/angular/src/.well-known/apple-app-site-association new file mode 100644 index 0000000000..4f0eede545 --- /dev/null +++ b/client/wfnews-war/src/main/angular/src/.well-known/apple-app-site-association @@ -0,0 +1,13 @@ +{ + "applinks": { + "apps": [], + "details": [ + { + "appID": "796QSLV3E.ca.bc.gov.WildfireInformation", + "paths": [ + "*" + ] + } + ] + } +} \ No newline at end of file From 1d1f231b50ec43a5246e68201d42d927f53bbdfb Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 30 Oct 2024 14:44:53 -0700 Subject: [PATCH 4/8] Update iOS capabitlities & entitlements and host URL in app.component.ts --- .../ios/App/App.xcodeproj/project.pbxproj | 26 ++++++++++--------- .../ios/App/App/AppRelease.entitlements | 12 +++++++++ .../src/main/angular/src/app/app.component.ts | 6 ++--- 3 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 client/wfnews-war/src/main/angular/ios/App/App/AppRelease.entitlements diff --git a/client/wfnews-war/src/main/angular/ios/App/App.xcodeproj/project.pbxproj b/client/wfnews-war/src/main/angular/ios/App/App.xcodeproj/project.pbxproj index 1b5342bc4d..fb4e2a79f0 100644 --- a/client/wfnews-war/src/main/angular/ios/App/App.xcodeproj/project.pbxproj +++ b/client/wfnews-war/src/main/angular/ios/App/App.xcodeproj/project.pbxproj @@ -1,4 +1,4 @@ -// !$*UTF8*$! +// !$UTF8$! { archiveVersion = 1; classes = { @@ -7,15 +7,15 @@ objects = { /* Begin PBXBuildFile section */ - 2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; }; - 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; }; - 504EC3081FED79650016851F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F /* AppDelegate.swift */; }; - 504EC30D1FED79650016851F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F /* Main.storyboard */; }; - 504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; }; - 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; }; - 50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; }; - A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; }; - FF55D6062A422B6100B95B2E /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FF55D6052A422B6100B95B2E /* GoogleService-Info.plist */; }; + 2FAD9763203C412B000D30F8 /* config.xml in Resources / = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 / config.xml */; }; + 50379B232058CBB4000EE86E /* capacitor.config.json in Resources / = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E / capacitor.config.json */; }; + 504EC3081FED79650016851F /* AppDelegate.swift in Sources / = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F / AppDelegate.swift */; }; + 504EC30D1FED79650016851F /* Main.storyboard in Resources / = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F / Main.storyboard */; }; + 504EC30F1FED79650016851F /* Assets.xcassets in Resources / = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F / Assets.xcassets */; }; + 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources / = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F / LaunchScreen.storyboard */; }; + 50B271D11FEDC1A000F3C39B /* public in Resources / = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B / public */; }; + A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks / = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 / Pods_App.framework */; }; + FF55D6062A422B6100B95B2E /* GoogleService-Info.plist in Resources / = {isa = PBXBuildFile; fileRef = FF55D6052A422B6100B95B2E / GoogleService-Info.plist */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -28,6 +28,7 @@ 504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = ""; }; + A80A0D5E2CD2DA7A0037C9CB /* AppRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AppRelease.entitlements; sourceTree = ""; }; AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = ""; }; FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = ""; }; @@ -76,6 +77,7 @@ 504EC3061FED79650016851F /* App */ = { isa = PBXGroup; children = ( + A80A0D5E2CD2DA7A0037C9CB /* AppRelease.entitlements */, FF2FE5852A7ACD86008F1385 /* App.entitlements */, FF55D6052A422B6100B95B2E /* GoogleService-Info.plist */, 50379B222058CBB4000EE86E /* capacitor.config.json */, @@ -379,7 +381,7 @@ baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_ENTITLEMENTS = App/App.entitlements; + CODE_SIGN_ENTITLEMENTS = App/AppRelease.entitlements; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 413; @@ -425,4 +427,4 @@ /* End XCConfigurationList section */ }; rootObject = 504EC2FC1FED79650016851F /* Project object */; -} +} \ No newline at end of file diff --git a/client/wfnews-war/src/main/angular/ios/App/App/AppRelease.entitlements b/client/wfnews-war/src/main/angular/ios/App/App/AppRelease.entitlements new file mode 100644 index 0000000000..ef9473ff63 --- /dev/null +++ b/client/wfnews-war/src/main/angular/ios/App/App/AppRelease.entitlements @@ -0,0 +1,12 @@ + + + + + aps-environment + development + com.apple.developer.associated-domains + + applinks://wildfiresituation.nrs.gov.bc.ca + + + \ No newline at end of file diff --git a/client/wfnews-war/src/main/angular/src/app/app.component.ts b/client/wfnews-war/src/main/angular/src/app/app.component.ts index 392bd26704..aa4dcd1bfc 100644 --- a/client/wfnews-war/src/main/angular/src/app/app.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/app.component.ts @@ -272,13 +272,13 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit { } initializeDeepLinks() { + // add listener to enable Capacitor deep links functionality App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => { this.zone.run(() => { - console.log('Deep link URL: ' + event.url); - const domain = 'bcwildfireservices.com'; + const domain = 'wildfiresituation.nrs.gov.bc.ca'; + // The pathArray is now like ['wildfiresituation.nrs.gov.bc.ca', '/map?longitude=-124.62025&latitude=53.231&activeWildfires=true'] const pathArray = event.url.split(domain); - // The pathArray is now like ['bcwildfireservices.com', '/map?longitude=-124.62025&latitude=53.231&activeWildfires=true'] // Get the last element with pop() const appPath = pathArray.pop(); From f30831d0d4f38692e6fcc68fe8c44819847873be Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Thu, 31 Oct 2024 12:16:07 -0700 Subject: [PATCH 5/8] Update AndroidManifest.xml --- .../src/main/angular/android/app/src/main/AndroidManifest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml b/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml index c93d2d7037..b35eb47f82 100644 --- a/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml +++ b/client/wfnews-war/src/main/angular/android/app/src/main/AndroidManifest.xml @@ -11,6 +11,8 @@ + + From 014daa1e17f93a168140d8570b08e0f74ee0aa3c Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Thu, 31 Oct 2024 12:33:26 -0700 Subject: [PATCH 6/8] Set domain for deepLinks based on environment --- client/wfnews-war/src/main/angular/src/app/app.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/wfnews-war/src/main/angular/src/app/app.component.ts b/client/wfnews-war/src/main/angular/src/app/app.component.ts index aa4dcd1bfc..e6cdc86317 100644 --- a/client/wfnews-war/src/main/angular/src/app/app.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/app.component.ts @@ -275,7 +275,8 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit { // add listener to enable Capacitor deep links functionality App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => { this.zone.run(() => { - const domain = 'wildfiresituation.nrs.gov.bc.ca'; + // remove https:// and http:// from baseUrl + const domain = this.appConfigService.getConfig().application.baseUrl.replace(/^https?:\/\//i, ''); // The pathArray is now like ['wildfiresituation.nrs.gov.bc.ca', '/map?longitude=-124.62025&latitude=53.231&activeWildfires=true'] const pathArray = event.url.split(domain); From 24ab3238b2dd5f81e811d0bd4ac236adda2ee3f7 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Thu, 31 Oct 2024 12:41:30 -0700 Subject: [PATCH 7/8] Update EXPORT_OPTIONS_PLIST to Github variables --- .github/workflows/ios.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 379a210bd1..6e06f44ef9 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -228,7 +228,7 @@ jobs: - name: Export IPA env: - EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST }} + EXPORT_OPTIONS_PLIST: ${{ vars.EXPORT_OPTIONS_PLIST }} run: | EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist echo -n "$EXPORT_OPTIONS_PLIST" | base64 --decode -o $EXPORT_OPTS_PATH From 2e8f97b6dfa853de1c25de2a8dc3ec3e1375e9d5 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Thu, 31 Oct 2024 12:49:57 -0700 Subject: [PATCH 8/8] Add all relevant applinks to entitlements for iOS --- .../ios/App/App/AppRelease.entitlements | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client/wfnews-war/src/main/angular/ios/App/App/AppRelease.entitlements b/client/wfnews-war/src/main/angular/ios/App/App/AppRelease.entitlements index ef9473ff63..67d5b79a4d 100644 --- a/client/wfnews-war/src/main/angular/ios/App/App/AppRelease.entitlements +++ b/client/wfnews-war/src/main/angular/ios/App/App/AppRelease.entitlements @@ -1,12 +1,14 @@ - - aps-environment - development - com.apple.developer.associated-domains - - applinks://wildfiresituation.nrs.gov.bc.ca - - + + aps-environment + development + com.apple.developer.associated-domains + + applinks://wfnews-client.dev.bcwildfireservices.com + applinks://wfnews-client.test.bcwildfireservices.com + applinks://wildfiresituation.nrs.gov.bc.ca + + \ No newline at end of file