闪屏的IONIC白屏问题在首次加载时挂起(iOS-ionic3)

时间:2018-12-29 09:39:50

标签: ios ionic-framework ionic2 ionic3

好的,我知道那里有很多类似的问题,但是我面临的问题略有不同。

实际上,当我使用Xcode10构建适用于iOS的Ionic3应用程序时,它可以完美构建,但是当该应用程序首次启动时,它会显示启动屏幕很长时间,然后白屏会保持无限时间,但是如果我最小化应用程序,然后再次打开,我看到所有内容都加载良好并且应用程序运行正常(我在iOS模拟器和设备上都面临此问题)。

每次我在关闭应用程序后启动应用程序时都会发生这种情况。但是在关闭它(不清除其任务)并再次打开它之后,它可以正常工作并且白屏消失。 尽管目前还没有很好的白屏相关解决方案,但我几乎尝试了所有方法,但问题仍然存在。请帮我。

PS:同一应用在调试和生产版本中(在模拟器以及设备上)在Android中均能完美运行。

我的package.json

{
  "name": "newApp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/app-version": "^4.13.0",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/fcm": "^4.5.2",
    "@ionic-native/google-analytics": "^4.13.0",
    "@ionic-native/push": "4.0.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "@types/lodash": "^4.14.91",
    "cordova-android": "^7.1.3",
    "cordova-ios": "4.5.5",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-google-analytics": "^1.8.6",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-statusbar": "^2.2.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "datepicker-ionic2": "^2.6.2",
    "highcharts": "^4.2.6",
    "ion2-calendar": "^2.2.0",
    "ionic-angular": "3.6.1",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionic-select-searchable": "^2.8.2",
    "ionicons": "3.0.0",
    "moment": "^2.22.2",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.1.4",
    "typescript": "2.3.4"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-google-analytics": {
        "GMS_VERSION": "11.0.1"
      }
    },
    "platforms": [
      "android",
      "ios"
    ]
  }
}

我的config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="newApp" version="24.6.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>New App</name>
    <description>An Inventory App</description>
    <author email="prashantjain.pro@gmail.com" href="">Prashant Jain</author>
    <content src="index.html" />
    <access origin="*" subdomains="true" />
    <allow-navigation href="*" />
    <allow-intent href="*" />
    <allow-navigation href="http://ionic.local/*" />
    <allow-navigation href="*://*vimeo.com" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="16" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />

    <preference name="AutohideSplashScreen" value="false" />
    <platform name="android">
        <allow-intent href="market:*" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
    </platform>
    <plugin name="cordova-plugin-device" spec="^1.1.4" />
    <plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
    <plugin name="cordova-plugin-statusbar" spec="^2.2.2" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
    <plugin name="cordova-plugin-app-version" spec="^0.1.9" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-google-analytics" spec="^1.8.6">
        <variable name="GMS_VERSION" value="11.0.1" />
    </plugin>
    <engine name="android" spec="^7.1.3" />
    <engine name="ios" spec="4.5.5" />
</widget>

1 个答案:

答案 0 :(得分:1)

嗯,我想出了确切的问题。这是由于在更改iOS平台版本时添加和删除了插件。由于device doesn't get ready before loading plugins

要解决此问题,请确保您已添加最新的iOS平台。然后开始逐个删除plugins folder中的插件。
要删除插件,请输入:
ionic cordova plugin rm <plugin-name>

如果存在其npm模块,请同时将其卸载:
npm uninstall --save <plugin-name>

确保以这种方式删除每个插件。然后,刷新您的项目或使用以下方法清理该项目:
npm run clean

然后,再次开始添加插件。用途:
ionic cordova plugin add <plugin-name>

npm install --save <plugin-name>

此后,只需使用以下命令再次构建项目:
ionic cordova build android --prod

一切都会正常。 :)

PS:如果在进行version 4 present, expected 3之类的构建时出现任何问题,则意味着您的项目是为ionic3编写的,因此,在这种情况下,您可能必须更改{{1 }}和@ionic-native/core版本,然后必须更改rxjs

希望,这将解决您的问题:)