我正在尝试找到一种使用电容器打开设置/首选项应用程序的方法,但未成功。
App.canOpenUrl({ url: 'com.apple.Preferences' })
失败,并显示错误消息-canOpenURL: failed for URL: "com.apple.Preferences" - error: "Invalid input URL"
我不确定是否做错了,或者是否有可能用电容器打开本机应用程序……?
this article显示了如何打开Facebook应用程序,但没有打开本机应用程序
答案 0 :(得分:1)
针对同样问题的人
安装:
cordova-open-native-settings
$ npm install cordova-open-native-settings
$ npm install @ionic-native/open-native-settings
$ ionic cap sync
app.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);
})
}
}