Help.. ionic 2 and ios 10. (The CSP struggle.)


#1

Hi, I am developing an app for android and iOS 10 with ionic 2/Angular 2.

My app works perfectly on android(5.0~7.0). But on iOS 10, my app wont get pass the white screen on startup.

My app uses angular2 http request to get JSON from my server, and few other cordova-plugins(Zip, File, File-Transfer). Also uses ionic2 storage(I did not install cordova sqlite).

I did days of searching about it and I believe the solution is in setting the Content-Security-Policy meta tags correctly.

However, I have tried various meta tags but unfortunately, I’m still stuck with white screen on iOS 10.
(Android work’s both with or without the CSP tag)

I have tried updating, re-installing all the components and the plugin. Adding, removing os platforms, ionic state reset etc… but still hopeless with no solution.

Here’s my current meta tag in ‘/src/index.html’ (inside head tag and above the title tag):
<meta http-equiv="Content-Security-Policy" content="default-src gap://ready file://* *; script-src 'self' 'unsafe-inline' 'unsafe-eval' data: *; style-src 'self' 'unsafe-inline' *; img-src 'self' data: blob: *; media-src 'self' mediastream: blob:; connect-src * blob:">

And my iOS emulator(iPhone SE iOS10.2) console log on starting my app:

Jan 17 19:48:24 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Pasteboard change listener callback port <NSMachPort: 0x7fac9ca1ed80> registered
Jan 17 19:48:41 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Pasteboard change listener callback port <NSMachPort: 0x7fac9c9010c0> registered
Jan 17 19:48:43 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Pasteboard change listener callback port <NSMachPort: 0x7fac9cc041f0> registered
Jan 17 19:48:43 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Pasteboard change listener callback port <NSMachPort: 0x7fac9ae032e0> registered
Jan 17 19:48:43 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Pasteboard change listener callback port <NSMachPort: 0x7fac9c809510> registered
Jan 17 19:48:44 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Pasteboard change listener callback port <NSMachPort: 0x7fac9af039f0> registered
Jan 17 19:48:44 baksagimms-Mac-Pro DTServiceHub[32275]: Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
Jan 17 19:48:45 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Pasteboard change listener callback port <NSMachPort: 0x7fac9c908d70> registered
Jan 17 19:48:45 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Requesting installation of file:///Users/blackstone/IdeaProjects/artistapp_dia/album_app/platforms/ios/build/emulator/album_app.app/ with options: {
CFBundleIdentifier = “com.ionicframework.albumapp837617”;
PackageType = Developer;
SimulatorRootPath = “/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk”;
SimulatorUserPath = “/Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data”;
}
Jan 17 19:48:45 baksagimms-Mac-Pro installd[32260]: 0x700001f6a000 -[MIClientConnection _doInstallationForURL:withOptions:completion:]: Install of “/Users/blackstone/IdeaProjects/artistapp_dia/album_app/platforms/ios/build/emulator/album_app.app” type Developer (LSInstallType = (null)) requested by CoreSimulatorBridge (pid 32274)
Jan 17 19:48:45 baksagimms-Mac-Pro installd[32260]: 0x700001f6a000 MDMCreateDeltaDirectory: calling MDMDirectoryDiff with:
state->old_bundle: /Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/E8A8A135-71C8-404A-8D36-501C7ECC02AC/album_app.app
state->new_bundle: /Users/blackstone/IdeaProjects/artistapp_dia/album_app/platforms/ios/build/emulator/album_app.app
state->dst_bundle: /Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Library/Caches/com.apple.mobile.installd.staging/temp.rfQKOU/extracted/Payload//album_app.app, binaryDiff flag: FALSE
dst_ipa: /Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Library/Caches/com.apple.mobile.installd.staging/temp.rfQKOU/extracted
Jan 17 19:48:45 baksagimms-Mac-Pro installd[32260]: 0x700001de1000 __MDMDirectoryDiff_block_invoke.37: calling writeDictToFile with: /Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Library/Caches/com.apple.mobile.installd.staging/temp.rfQKOU/extracted/ManifestCache.plist
Jan 17 19:48:45 baksagimms-Mac-Pro installd[32260]: 0x700001de1000 writeDictToFile: ==== Successfully wrote Manifest cache to /Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Library/Caches/com.apple.mobile.installd.staging/temp.rfQKOU/extracted/ManifestCache.plist
Jan 17 19:48:46 baksagimms-Mac-Pro SpringBoard[32264]: [KeyboardArbiter] HW kbd: Failed to set (null) as keyboard focus
Jan 17 19:48:46 baksagimms-Mac-Pro installd[32260]: 0x700001f6a000 -[MIInstaller performInstallationWithError:]: Installing
Jan 17 19:48:46 baksagimms-Mac-Pro installd[32260]: 0x700001f6a000 -[MIInstallableBundlePatch applyPatchWithError:]: Attempting patch update of com.ionicframework.albumapp837617 from 0.0.1 (0.0.1) to 0.0.1 (0.0.1)
Jan 17 19:48:46 baksagimms-Mac-Pro com.apple.CoreSimulator.SimDevice.BA74E51F-A0B7-4662-B483-EE053FA53DAB.launchd_sim[32248] (UIKitApplication:com.ionicframework.albumapp837617[0x6f91][32345]): Service exited due to Killed: 9
Jan 17 19:48:46 baksagimms-Mac-Pro backboardd[32266]: [Common] Unable to get short BSD proc info for 32345: No such file or directory
Jan 17 19:48:46 baksagimms-Mac-Pro backboardd[32266]: [Common] Unable to get proc info for 32345: No such file or directory
Jan 17 19:48:46 baksagimms-Mac-Pro assertiond[32269]: notify_suspend_pid() failed with error 7
Jan 17 19:48:47 baksagimms-Mac-Pro syslogd[32250]: Disabling module com.apple.appinstallation writes to /var/mobile/Library/Logs/CrashReporter/DiagnosticLogs/AppInstallation/AppInstallation.log following 6 failures (Operation Failed)
Jan 17 19:48:47 baksagimms-Mac-Pro installd[32260]: 0x700001f6a000 -[MIInstallableBundle _refreshUUIDForContainer:withError:]: Data container for com.ionicframework.albumapp837617 is now at /Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Data/Application/1EE6DD04-3B43-4E5B-9A00-01841C9DD3A1
Jan 17 19:48:47 baksagimms-Mac-Pro installd[32260]: 0x700001f6a000 -[MIContainer makeContainerLiveReplacingContainer:reason:withError:]: Made container live for com.ionicframework.albumapp837617 at /Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3
Jan 17 19:48:47 baksagimms-Mac-Pro installd[32260]: 0x700001f6a000 -[MIInstaller performInstallationWithError:]: Install Successful; Staging: 1.50s; Waiting: 0.00s; Preflight/Patch: 0.44s, Verifying: 0.01s; Overall: 2.05s
Jan 17 19:48:47 baksagimms-Mac-Pro appstored[32330]: [default] LaunchServices observer: Installed (
"<LSApplicationProxy: 0x7ff453f08c40> com.ionicframework.albumapp837617 file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app <com.ionicframework.albumapp837617 >"
) {A703FE87-2740-4C0B-8AA7-9125511A3381 256}
Jan 17 19:48:47 baksagimms-Mac-Pro SpringBoard[32264]: [default] LaunchServices observer: Installed (
"<LSApplicationProxy: 0x7fe7d091fcc0> com.ionicframework.albumapp837617 file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app <com.ionicframework.albumapp837617 >"
) {A703FE87-2740-4C0B-8AA7-9125511A3381 256}
Jan 17 19:48:47 baksagimms-Mac-Pro routined[32254]: [default] LaunchServices observer: Installed (
"<LSApplicationProxy: 0x7feb6d615da0> com.ionicframework.albumapp837617 file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app <com.ionicframework.albumapp837617 >"
) {A703FE87-2740-4C0B-8AA7-9125511A3381 256}
Jan 17 19:48:47 baksagimms-Mac-Pro nsurlsessiond[32302]: [default] LaunchServices observer: Installed (
"<LSApplicationProxy: 0x7ff8a2205aa0> com.ionicframework.albumapp837617 file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app <com.ionicframework.albumapp837617 >"
) {A703FE87-2740-4C0B-8AA7-9125511A3381 256}
Jan 17 19:48:47 baksagimms-Mac-Pro UserEventAgent[32251]: [default] LaunchServices observer: Installed (
"<LSApplicationProxy: 0x7fc3fc705ca0> com.ionicframework.albumapp837617 file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app <com.ionicframework.albumapp837617 >"
) {A703FE87-2740-4C0B-8AA7-9125511A3381 256}
Jan 17 19:48:47 baksagimms-Mac-Pro passd[32319]: [default] LaunchServices observer: Installed (
"<LSApplicationProxy: 0x7f8965003f40> com.ionicframework.albumapp837617 file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app <com.ionicframework.albumapp837617 >"
) {A703FE87-2740-4C0B-8AA7-9125511A3381 256}
Jan 17 19:48:47 baksagimms-Mac-Pro SpringBoard[32264]: [default] LaunchServices observer: Installed (
"<LSApplicationProxy: 0x7fe7ce55a540> com.ionicframework.albumapp837617 file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app <com.ionicframework.albumapp837617 >"
) {A703FE87-2740-4C0B-8AA7-9125511A3381 256}
Jan 17 19:48:47 baksagimms-Mac-Pro profiled[32321]: [default] LaunchServices observer: Installed (
"<LSApplicationProxy: 0x7ffbc390f740> com.ionicframework.albumapp837617 file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app <com.ionicframework.albumapp837617 >"
) {A703FE87-2740-4C0B-8AA7-9125511A3381 256}
Jan 17 19:48:51 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Pasteboard change listener callback port <NSMachPort: 0x7fac9cd09750> registered
Jan 17 19:48:51 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Requesting launch of com.ionicframework.albumapp837617 with options: {
environment = {
};
}
Jan 17 19:48:51 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Beginning launch sequence for bundle 'com.ionicframework.albumapp837617’
retryTimeout: 120.000000 (default write com.apple.CoreSimulatorBridge LaunchRetryTimeout )
bootTimeout: 300.000000 (default write com.apple.CoreSimulatorBridge BootRetryTimeout )
bootLeeway: 120.000000 (default write com.apple.CoreSimulatorBridge BootLeeway )
Note: Use 'xcrun simctl spawn booted defaults write ’ to modify defaults in the booted Simulator device.
Simulator booted at: 2017-01-17 10:27:11 +0000
Current time: 2017-01-17 10:48:51 +0000
Within boot leeway: NO
Jan 17 19:48:51 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Launch attempt #0 for bundle ‘com.ionicframework.albumapp837617’, have been trying to launch for 0 seconds. Modern launch services = YES
Jan 17 19:48:51 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Got LSBundleProxy for ‘com.ionicframework.albumapp837617’, sequenceNumber 256, cacheGUID A703FE87-2740-4C0B-8AA7-9125511A3381
Jan 17 19:48:51 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: [Common] [FBSSystemService][0xed8e] Sending request to open "com.ionicframework.albumapp837617"
Jan 17 19:48:51 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: [Common] [FBSSystemService][0xed8e] Request successful: <FBSProcessHandle: 0x7fac9c805d50; album_app:32697; valid: YES>
Jan 17 19:48:51 baksagimms-Mac-Pro CoreSimulatorBridge[32274]: Launch successful for 'com.ionicframework.albumapp837617’
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: objc[32697]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x1061fe998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x105f7d880). One of the two will be used. Which one is undefined.
Jan 17 19:48:52 baksagimms-Mac-Pro logd[32259]: metadata shared cached uuid is null (using logd’s shared cache info) album_app (32697)
Jan 17 19:48:52 baksagimms-Mac-Pro logd[32259]: Failed to harvest strings for pathless uuid '00000000-0000-0000-0000-000000000000’
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: assertion failed: 16C67 14C89: libxpc.dylib + 62677 [0339A402-6531-30E9-8BC2-589C463CD6D6]: 0x7d
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: Apache Cordova native platform version 4.3.1 is starting.
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: Multi-tasking -> Device: YES, App: YES
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: Using UIWebView
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: [CDVTimer][handleopenurl] 0.047028ms
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: Unlimited access to network resources
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: [CDVTimer][intentandnavigationfilter] 1.711011ms
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: [CDVTimer][gesturehandler] 0.056982ms
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: [CDVTimer][file] 2.811015ms
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: [CDVTimer][splashscreen] 16.559005ms
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: [CDVTimer][statusbar] 4.653037ms
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: [CDVTimer][keyboard] 0.611007ms
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: [CDVTimer][TotalPluginStartup] 28.108001ms
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: Resetting plugins due to page load.
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: Finished load of: file:///Users/blackstone/Library/Developer/CoreSimulator/Devices/BA74E51F-A0B7-4662-B483-EE053FA53DAB/data/Containers/Bundle/Application/6D2D037E-10B7-43E0-B95B-709FCB9493F3/album_app.app/www/index.html
Jan 17 19:48:52 baksagimms-Mac-Pro album_app[32697]: DEVICE READY FIRED AFTER 55 ms

App will work just fine on iOS10 if no additional cordova plugins are installed.
Anyone who has any info or solution about this please help.
Thank you.


#2

Hello I’m crazy about this problem, my app was regeitado in the app store because they could not open in devices with ios 10.2 it hangs on the home screen, I did as you found several solutions with goal change plus no worked out I heard you say it works without Plugin and then I simply made 9 builder until I figured out which plugin caused the error and is exactly without it everything works and it causes an error soon on the white screen home screen unfortunately Has no fix until now or downgrade to previous versions unfortunately, until someone there of the plugin solves the problem the way is to use other unofficial plugins temporarily, I hope someone finds the solution fast because 99% of apps in phonegap use this plugin .


#3

Hi, thanks for reply. thank god im not the only one.
one thing may i ask?
when you said about downgrading, did that mean if you downgrade some specific plugin it will work on ios10? if its true, did you find out which plugin causing the problem?


#4

Yes I am 3 days without sleep trying to find a solution, I have 8 plugins I did 8 bulids and debugs until I find the splash screen plugin that causes the error, remove it and the application will load without any problem, I tried old versions but they do not work The only solution is to leave without splash or look for another plugin, it’s a shame that the team has not discovered a solution to this 99% of the App in Cordova use this plugins as default and will have problems updating their applications for iOS from now on, I hope That someone can help to update this plugin or give another alternative option.


#5

something i found out: in my case it wasn’t about the plugins.
when i use the cordova-file plugin i have to declare let cordova:any; outside the page class so i can get the application’s directory by doing cordova.file.dataDirectory. but that was the cause of the problem in iOS10.
but now i’m let with no clue on how i should get the application directory url without declaring cordova in my ionic 2 project.


#6

Hello I discovered the source of the problem, I was successfully using the option to manage the time of my splash by the code, however from 10.2 something goes wrong and the screen So I had to re-include the option to auto hide as true, so now the app does not hang anymore follows the full list of splash screen preferences:

Plugin version Config.xml

<Plugin name = "cordova-plugin-splashscreen" source = "npm" spec = "4.0.1" />

   <Preference name = "SplashScreen" value = "screen" />
   <Preference name = "AutoHideSplashScreen" value = "true" />
   <Preference name = "ShowSplashScreenSpinner" value = "true" />
   <Preference name = "FadeSplashScreen" value = "true" />
   <Preference name = "FadeSplashScreenDuration" value = "1.0" />
   <Preference name = "SplashScreenDelay" value = "100" />
   <Preference name = "SplashScreenBackgroundColor" value = "# FE5D01" />
   <Preference name = "SplashMaintainAspectRatio" value = "true" />