Open clampinou opened 3 years ago
I'm having the same issue. My project is built on top of capacitor.
The performActionForShortcutItem
is never called.
@clampinou did you find any solution to this?
Hi all, I'm having the same issue. Here it is my project env:
Ionic:
Ionic CLI : 6.12.1
Ionic Framework : @ionic/angular 5.3.1
@angular-devkit/build-angular : 0.1000.5
@angular-devkit/schematics : 9.1.12
@angular/cli : 9.1.12
@ionic/angular-toolkit : 2.2.0
Capacitor:
Capacitor CLI : 2.4.0
@capacitor/core : 2.4.0
Utility:
cordova-res (update available: 0.15.2) : 0.15.1
native-run : not installed
System:
NodeJS : v12.16.1
npm : 6.13.4
OS : macOS Catalina
@EddyVerbruggen any chance you can have a look at it?
Here is a way to avoid this problem:
Native part:
Add this code to AppDelegate.swift
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let webView = self.window?.rootViewController?.view as? WKWebView;
webView?.evaluateJavaScript("window.shortcutItemType = '\(shortcutItem.type)'")
}
TypeScript part:
When the application starts you can exmine this variable eg.: (window as any).shortcutItemType
. So if this variable is not null, quick start is needed.
@csmark97 thank you very much for your suggestion, works perfectly for me! To also make it work when the app is still in background I use this piece of code for my capacitor app:
App.addListener("appStateChange", (change) => {
if (change.isActive && (window as any).shortcutItemType) {
this.navigateToPageById((window as any).shortcutItemType);
(window as any).shortcutItemType = null;
}
});
@NLueg Hi, Sir. i have the same problem, but your method doesn't helped :( shortcuts appears but no reaction on onHomeIconPressed. i got the same error about INVALID options. I'l be glad if you share a piece of your code. maybe i'm doing it wrong.
Hey @Rom3ik, I actually don't use this plugin, but I moved to https://github.com/NePheus/capacitor-android-shortcuts which works pretty well for me. But I don't think that the opening of Item is different here. I can still share you my code which is a bit different from what I mentioned above:
AppDelegate.swift
:
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let webView = self.window?.rootViewController?.view as? WKWebView;
webView?.evaluateJavaScript("window.shortcutItemType = '\(shortcutItem.type)'")
}
x.service.ts
:
constructor(deviceService: DeviceService) {
if (this.deviceService.isIos) {
if ((window as any).shortcutItemType) {
this.navigateToPageById((window as any).shortcutItemType);
(window as any).shortcutItemType = null;
}
App.addListener('appStateChange', (change) => {
if (change.isActive && (window as any).shortcutItemType) {
this.navigateToPageById((window as any).shortcutItemType);
(window as any).shortcutItemType = null;
}
});
}
}
For Android, it's actually pretty straightforward with the mentioned plugin. Only iOS requires this workaround.
NLueg Thanks a lot for reply. I'll check it out. Have a good day.
we also face same issue
does anyone fix issue
Ionic:
Ionic CLI : 6.20.8 (/usr/local/lib/node_modules/@ionic/cli) Ionic Framework : 7.0.5 @angular-devkit/build-angular : 15.2.6 @angular-devkit/schematics : 15.2.6 @angular/cli : 15.2.6 @ionic/angular-toolkit : 9.0.0
Capacitor:
Capacitor CLI : 4.7.3 @capacitor/android : 4.7.3 @capacitor/core : 4.7.3 @capacitor/ios : 4.7.3
Utility:
cordova-res : 0.15.4 native-run : 1.7.2
System:
NodeJS : v14.20.0 (/usr/local/bin/node) npm : 6.14.17 OS : macOS
Hi!
I saw all issues about it but nothing working for me... Subscribing to onHomeIconPressed does nothing, even in "platform.ready().then()"... Besides, I have another error that I can't explain:
Maybe my problem comes from here? 👆
I'm using:
In my app.module.ts (am I forgetting something here maybe?):
My app.component.ts code:
And here is my XCode log:
If anybody can help... 🙏