Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFNEWS-2055 Enabling Capacitor Deep Links in standalone apps #2110

Merged
merged 11 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:requestLegacyExternalStorage="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:name=".MainActivity" android:label="@string/title_activity_main" android:theme="@style/AppTheme.NoActionBarLaunch" android:launchMode="singleTask" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="wfnews-client.dev.bcwildfireservices.com" />
<data android:scheme="https" android:host="wfnews-client.test.bcwildfireservices.com" />
<data android:scheme="https" android:host="wildfiresituation.nrs.gov.bc.ca" />
sukhpalp marked this conversation as resolved.
Show resolved Hide resolved
</intent-filter>
</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
Expand Down
5 changes: 5 additions & 0 deletions client/wfnews-war/src/main/angular/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"glob": "bc-sans/**/*",
"input": "node_modules/@wf1/wfcc-application-ui",
"output": "assets"
},
{
"glob": "**/*",
"input": "src/.well-known",
sukhpalp marked this conversation as resolved.
Show resolved Hide resolved
"output": ".well-known/"
}
],
"styles": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// !$*UTF8*$!
// !$UTF8$!
{
archiveVersion = 1;
classes = {
Expand All @@ -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 */
Expand All @@ -28,6 +28,7 @@
504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
A80A0D5E2CD2DA7A0037C9CB /* AppRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AppRelease.entitlements; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
Expand Down Expand Up @@ -76,6 +77,7 @@
504EC3061FED79650016851F /* App */ = {
isa = PBXGroup;
children = (
A80A0D5E2CD2DA7A0037C9CB /* AppRelease.entitlements */,
FF2FE5852A7ACD86008F1385 /* App.entitlements */,
FF55D6052A422B6100B95B2E /* GoogleService-Info.plist */,
50379B222058CBB4000EE86E /* capacitor.config.json */,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -425,4 +427,4 @@
/* End XCConfigurationList section */
};
rootObject = 504EC2FC1FED79650016851F /* Project object */;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks://wfnews-client.dev.bcwildfireservices.com</string>
<string>applinks://wfnews-client.test.bcwildfireservices.com</string>
<string>applinks://wildfiresituation.nrs.gov.bc.ca</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"applinks": {
"apps": [],
"details": [
{
"appID": "796QSLV3E.ca.bc.gov.WildfireInformation",
"paths": [
"*"
]
}
]
}
}
14 changes: 14 additions & 0 deletions client/wfnews-war/src/main/angular/src/.well-known/assetlinks.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
]
113 changes: 67 additions & 46 deletions client/wfnews-war/src/main/angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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<any>)
Expand Down Expand Up @@ -269,6 +271,25 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit {
}
}

initializeDeepLinks() {
// add listener to enable Capacitor deep links functionality
App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => {
this.zone.run(() => {
// 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);

// Get the last element with pop()
const appPath = pathArray.pop();
if (appPath) {
this.router.navigateByUrl(appPath);
}
});
});
}

isIncidentsPage() {
return (
window.location.pathname === '/incidents' ||
Expand Down Expand Up @@ -370,52 +391,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() {
Expand Down Expand Up @@ -956,7 +977,7 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit {
}
}

private updateMapSize = function() {
private updateMapSize = function () {
this.storeViewportSize();
};
}
Loading