我试图找到一种方法来打开设置/首选项应用程序与电容器,但我没有成功。
App.canOpenUrl({ url: 'com.apple.Preferences' })失败,并显示错误消息-canOpenURL: failed for URL: "com.apple.Preferences" - error: "Invalid input URL"
我不确定我是不是做错了,或者是否可以使用电容器打开本机应用程序…?
this article展示了如何打开facebook应用程序,但没有介绍原生应用程序
发布于 2020-05-13 20:12:13
对于有同样问题的人来说
安装:cordova-open-native-settings
$ npm install cordova-open-native-settings
$ npm install @ionic-native/open-native-settings
$ ionic cap syncapp.module.ts
// ...
import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';
@NgModule({
declarations: [
// ...
],
entryComponents: [
// ...
],
imports: [
// ...
],
providers: [
// ...
OpenNativeSettings,
],
bootstrap: [AppComponent]
})
export class AppModule {}
whatever.page.ts
// ...
import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';
@Component({
selector: 'app-whatever',
templateUrl: './whatever.page.html',
styleUrls: ['./whatever.page.scss'],
})
export class PopoverComponent implements OnInit {
constructor(
// ...
private nativeSettings: OpenNativeSettings
) { }
phoneSettings() {
this.nativeSettings
.open('settings')
.then( res => {
console.log(res);
})
.catch( err => {
console.log(err);
})
}
}
发布于 2021-10-08 17:40:49
现在有一个电容器插件来解决这个问题,capacitor native settings。
它类似于cordova插件,但您必须为每个平台(iOS或安卓)调用正确的函数,而不是为两个平台都使用一个函数。
https://stackoverflow.com/questions/61103010
复制相似问题