2 Replies Latest reply on Aug 2, 2017 4:46 AM by pankajs74700703

    ios device is not getting initialized

    pankajs74700703

      Hi,

      I am new to PhoneGap. I have developed one app for iOS and android. The iOS is not getting initialized properly. During debugging, I observed that the call to deviceReady() is not happening in iOS. The same code works perfectly in android devices.

       

      In index.html, I have following meta tags

       

      <meta charset="utf-8">

      <meta http-equiv="Access-Control-Allow-Origin" content="*">      

      <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />

      <meta http-equiv="Content-Security-Policy" content="default-src * 'self' gap://ready file:; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval';  frame-src * https://cordova.apache.org; media-src *; img-src * filesystem: data:">

       

      Calling the deviceready

      document.addEventListener("deviceready", onDeviceReady, false);

      function onDeviceReady() {

        ---

      }

       

      Please let me know how to fix it.

        • 1. Re: ios device is not getting initialized
          kerrishotts Adobe Employee

          Some thoughts:

           

          • Are you sourcing "cordova.js" in your index.html file?
          • Make sure you aren't providing your own "cordova.js" file -- the build process will take care of that for you.
          • What plugins do you have installed? It might help to see the entirety of your config.xml (minus identifying/secret info)
          • 2. Re: ios device is not getting initialized
            pankajs74700703 Level 1

            I try to remove cordova.js which I was sourcing and build app, but got

            exception nativeEvalAndFetch : ReferenceError: Can't find variable: cordova

            and no device ready event fired.

            Following is my config.xml file, please have a look..

            <?xml version='1.0' encoding='utf-8'?>

            <widget id="---"

                version="1.0.4"

                xmlns="http://www.w3.org/ns/widgets"

                xmlns:gap="http://phonegap.com/ns/1.0"

                xmlns:android="http://schemas.android.com/apk/res/android"

                xmlns:cdv="http://cordova.apache.org/ns/1.0">

                <name>StartupBay</name>

                <description>

                    A StartupBay community app for andriod and iOS devices

                </description>

                <author email="----" href="---">

                    -----

                </author>

                   

                <content src="index.html" />

                <access origin="*" />

                <allow-navigation href="*"/>

                <allow-navigation href="http://*/*" />

               

                <!-- <preference name="StatusBarOverlaysWebView" value="true" /> -->

                <preference name="StatusBarBackgroundColor" value="#ff0" />

                <preference name="StatusBarStyle" value="lightcontent" />

                <preference name="WindowsToastCapable" value="true" />

                <preference name="DisallowOverscroll" value="true" />

                <preference name="android-windowSoftInputMode" value="adjustResize" /> <!-- adjustResize|adjustPan -->

            <preference name="fullscreen" value="false" />

                

                <preference name="SplashScreen" value="www/splash/splash.png" />

                <preference name="SplashScreenDelay" value="1000" />

                <preference name="SplashMaintainAspectRatio" value="true" />

                <preference name="AutoHideSplashScreen" value="true" />

                <preference name="ShowSplashScreenSpinner" value="false"/>

                <preference name="KeyboardShrinksView " value="true" />

                 <preference name="FadeSplashScreen" value="false"/>

             

               

                <feature name="http://api.phonegap.com/1.0/camera"/>

                 <feature name="http://api.phonegap.com/1.0/contacts"/>

                 <feature name="http://api.phonegap.com/1.0/file"/>

                 <feature name="http://api.phonegap.com/1.0/geolocation"/>

                 <feature name="http://api.phonegap.com/1.0/media"/>

                 <feature name="http://api.phonegap.com/1.0/network"/>

                 <feature name="http://api.phonegap.com/1.0/notification"/>

                 <feature name="StatusBar">

                        <param name="ios-package" value="CDVStatusBar" onload="true" />

                </feature>   

                <feature name="Notification">

                    <param name="android-package" value="org.apache.cordova.dialogs.Notification" />

                    <!--param name="wp-package" value="Notification"/-->

                </feature>

             

            <feature name="DatePicker">

               <param name="ios-package" value="DatePicker"/>

            </feature>

             

            <feature name="DatePickerPlugin">

               <param name="android-package" value="com.plugin.datepicker.DatePickerPlugin"/>

            </feature>

             

            <feature name="Keyboard">

               <param name="ios-package" value="IonicKeyboard" onload="true"/>

            </feature>

                   

                <plugin name="cordova-plugin-statusbar" spec="~2.1.2" />

                <plugin name="cordova-plugin-dialogs"   source="npm" spec="~1.2.1" />  

                <plugin name="cordova-plugin-camera"    source="npm" spec="~2.1.1" />  

                <plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />  

                 

                <plugin name="phonegap-plugin-push" source="npm" spec="~1.8.0">

                    <variable name="SENDER_ID" value="XXXXXXX" />

                </plugin>

                <plugin name="cordova-plugin-console" source="npm" spec="~1.0.3" />

                <plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.7.1"/>

                <plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.2"/>

                <plugin name="cordova-plugin-network-information" source="npm" />

               

                <allow-intent href="http://*/*" />

                <allow-intent href="https://*/*" />

                <allow-intent href="tel:*" />

                <allow-intent href="sms:*" />

                <allow-intent href="mailto:*" />

                <allow-intent href="geo:*" />

               

                <icon src="www/splash/icon/icon.png" />

                <splash src="www/splash/splash.png" />

                

                <platform name="browser">

                    <preference name="SplashScreen" value="splash/splash.png" /> <!-- defaults to "/img/logo.png" -->

                    <preference name="SplashScreenDelay" value="1000" /> <!-- defaults to "3000" -->

                    <preference name="SplashScreenBackgroundColor" value="red" /> <!-- defaults to "#464646" -->

                    <preference name="ShowSplashScreen" value="true" /> <!-- defaults to "true" -->

                    <preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->

                    <preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->

                </platform>

             

                <platform name="android">

                    <allow-intent href="market:*" />

                    <!--

                    APP icon configuration

                        ldpi    : 36x36 px

                        mdpi    : 48x48 px

                        hdpi    : 72x72 px

                        xhdpi   : 96x96 px

                        xxhdpi  : 144x144 px

                        xxxhdpi : 192x192 px

                    -->

                    <icon src="www/splash/icon/ldpi.png" density="ldpi" />

                    <icon src="www/splash/icon/mdpi.png" density="mdpi" />

                    <icon src="www/splash/icon/hdpi.png" density="hdpi" />

                    <icon src="www/splash/icon/xhdpi.png" density="xhdpi" />

                    <icon src="www/splash/icon/xxhdpi.png" density="xxhdpi" />

                    <icon src="www/splash/icon/xxxhdpi.png" density="xxxhdpi" />

             

                    <!--

                    Splash Screen Configuration

                     -->

                    <!-- you can use any density that exists in the Android project -->

                    <splash src="www/splash/splash.png" />

                   

                    <splash src="www/splash/splash-land-hdpi.png" qualifier="hdpi"/>

                    <splash src="www/splash/splash-land-ldpi.png" qualifier="ldpi"/>

                    <splash src="www/splash/splash-land-mdpi.png" qualifier="mdpi"/>

                    <splash src="www/splash/splash-land-xhdpi.png" qualifier="xhdpi"/>

             

                    <splash src="www/splash/splash-port-hdpi.png" qualifier="port-hdpi"/>

                    <splash src="www/splash/splash-port-ldpi.png" qualifier="port-ldpi"/>

                    <splash src="www/splash/splash-port-mdpi.png" qualifier="port-mdpi"/>

                    <splash src="www/splash/splash-port-xhdpi.png" qualifier="port-xhdpi"/>

             

                </platform>

                <platform name="ios">

                    <allow-intent href="itms:*" />

                    <allow-intent href="itms-apps:*" />

                    <!-- Splash screen images -->

            <!-- iPhone and iPod touch -->

                    <splash src="www/splash/splash-default.png" platform="ios" width="320" height="480" />

                    <splash src="www/splash/splash-default@2x.png" platform="ios" width="640" height="960" />

             

                    <!-- iPhone 5 / iPod Touch (5th Generation) -->

                    <splash src="www/splash/splash-default-568h@2x.png" platform="ios" width="640" height="1136" />

             

                    <!-- iPhone 6 -->

                    <splash src="www/splash/splash-default-667h@2x.png" platform="ios" width="750" height="1334" />

                    <splash src="www/splash/splash-default-Portrait-736h@3x.png" platform="ios" width="1242" height="2208" />

                    <splash src="www/splash/splash-default-Landscape-736h@3x.png" platform="ios" width="2208" height="1242" />

             

             

                    <!-- iPad -->

                    <splash src="www/splash/splash-default-Portrait.png" platform="ios" width="768" height="1024" />

                    <splash src="www/splash/splash-default-Landscape.png" platform="ios" width="1024" height="768" />

             

                    <!-- Retina iPad -->

                    <splash src="www/splash/splash-default-Portrait@2x.png" platform="ios" width="1536" height="2048" />

                    <splash src="www/splash/splash-default-Landscape@2x.png" platform="ios" width="2048" height="1536" />

                    <!-- Default splash screen -->

                    <splash src="www/splash/splash.png" />

             

                    <!-- APP icon configuration -->

                    <icon src="www/splash/icon.png" />

                    <!-- iPhone 6 / 6+ -->

                    <icon src="www/splash/icon/icon-60@3x.png" width="180" height="180" />

             

                    <!-- iPhone / iPod Touch  -->

                    <icon src="www/splash/icon/icon-60.png" width="60" height="60" />

                    <icon src="www/splash/icon/icon-60@2x.png" width="120" height="120" />

             

                    <!-- iPad -->

                    <icon src="www/splash/icon/icon-76.png" width="76" height="76" />

                    <icon src="www/splash/icon/icon-76@2x.png" width="152" height="152" />

                    <icon src="www/splash/icon/icon-83.5@2x.png" width="167" height="167" />

             

                    <!-- Settings Icon -->

                    <icon src="www/splash/icon/icon-small.png" width="29" height="29" />

                    <icon src="www/splash/icon/icon-small@2x.png" width="58" height="58" />

                    <icon src="www/splash/icon/icon-small@3x.png" width="87" height="87" />

             

                    <!-- Spotlight Icon -->

                    <icon src="www/splash/icon/icon-40.png" width="40" height="40" />

                    <icon src="www/splash/icon/icon-40@2x.png" width="80" height="80" />

                    <icon src="www/splash/icon/icon-40@3x.png" width="120" height="120" />

                </platform>

                <gap:config-file platform="ios" parent="NSCameraUsageDescription" overwrite="true">

                    <string>We are using the Camera for taking user profile photo</string>

                </gap:config-file>

                <gap:config-file platform="ios" parent="NSPhotoLibraryUsageDescription" overwrite="true">

                    <string>We are using the photo library for selecting the user profile photo</string>

                </gap:config-file>

            </widget>

             

             

            thanks