检查设备的 运行 cordova

Check if device's running cordova

我已经准备好 Web 应用程序并且我已经使用 Cordova 从中制作了一个 android 应用程序,它运行良好,但是当我这样做时:

 if (!(<any>window).cordova) {
      return this.afAuth.signInWithPopup(provider)
        .then(res => {
          this.ngZone.run(() => {
            this.router.navigate(['main-layout']);
          });
        }).catch(error => {
          window.alert(error);
        });
 } else {
   return this.afAuth.signInWithRedirect(provider);
 }

我预计在 android 上应用 else 会达到,但没有。

那么,我如何检查应用程序是 android (cordova) 上的 运行 还是 Angular 中的桌面?

我试过这个 ,但它对我没有帮助。

我正在使用 cordova 9,angular10。

谢谢。

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-device/index.html

这是获取cordova设备平台的参考,可以使用cmd添加:

cordova plugin add cordova-plugin-device

属性:

  • device.cordova

  • device.model

  • device.platform

  • device.uuid

  • device.version

  • device.manufacturer

  • device.isVirtual

  • device.serial

您可以使用 device.platform 来实现您需要的功能,例如:

if (device.platform === 'iOS') {}
if (device.platform === 'browser') {}
if (device.platform === 'Android') {}

您可以在上面的 link 中查看完整文档以查看更多内容或其他支持的平台