Hi I am building an app using ionic 3 and I have stumbled upon an issue regarding SplashScreen when permissions are requested.
To be exact, the permission pop-up displays the following message:
Allow $APPNAME to access photos, media, and files on your device?
When an app requires permissions, there is no splashscreen at the first run of the app.
When the permissions are removed using the custom-config-plugin
splashscreen is never displayed.
The desired behaviour is to not request permissions when the app is started, but request them when they are actually needed.
I've used a default ionic app (tabs theme) to explain it as best as possible.
There are 3 distinct states of the (demo) app:
When I have an app that
needs no permissions
the SplashScreen actsas expected
.By adding a plugin that requires
permissions
, there is arequest
box at thefirst run
of the app, but there isno splashscreen
after. Although in case Ikill and re-run
the app afterwards, the SplashScreen actsas expected
.- related repo: https://github.com/blver/ionic-permissions-splashscreen
- apk produced (debug mode): https://github.com/blver/ionic-permissions-splashscreen/tree/master/apk
Then I tried to
remove the permissions
(so they are not requested at the first run), and try to request them when they are actually needed, depending on the user's actions for better UX. I used thecustom-config-plugin
('https://github.com/dpa99c/cordova-custom-config') and managed to have theexact same AndroidManifest.xml
(in platforms/android) file as in state #1. The result was that splash screen is never shown at any run of the app.- related repo: https://github.com/blver/ionic-permissions-custom-config
- apk produced (debug mode): https://github.com/blver/ionic-permissions-custom-config/tree/master/apk
To sum it up, when a plugin requires permissions, there is no splash screen at the first run only. If I try to use the custom-config-plugin to remove said permissions, splash screen is never displayed.
Are there any suggestions on how to manage to:
1.have splash screen
2.not have a request for permissions when starting the app (while the plugin stays and permissions are handled when needed) ?
Below I include the file AndroidManifest.xml per state:
1
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
</manifest>
2
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
3 (Identical to #1)
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
</manifest>