• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by brklemz · Jun 28, 2017 at 09:07 PM · iphonenot workinggpsinitialization

GPS on iPhone 6 giving me fits, will not Initialize and never asks me to enable

I searched the Answers and Forums and I think I am doing it right but GPS will not Initialize on my iPhone. I am current w Unity, Xcode, my Apple fees are all paid and I used the correct team ID, and iOS on my iPhone 6 is also current. Here's my code (see below).

What happens when I run this: I get the timer counting down and then it simply times out, I never get the GPS coords.

I Build via Unity, I Run the xcodeproj via Xcode, Xcode puts the app on my phone, the icon looks fine and it runs when tapped, but GPS coords do not appear and the timer times out. OH, and the app does not show up in the Settings list of apps (weird).

What am I doing wrong?

Do I need to authorize something? Do I need to change something in my phone's settings? Do I need to do something different in separate linked file somewhere?

Any help from you folks will save me the little hair I have left. Thanks.....

=================

 private IEnumerator StartLocationServices()
 {
     if (!Input.location.isEnabledByUser)
     {
         gpsText.text = "ERROR: GPS is not enabled, cannot continue";
         yield break;
     }

     // Start service before querying location
     Input.location.Start(10, 10);

     // Wait until service initializes
     int maxWait = 20;
     while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) 
     {
         yield return new WaitForSeconds(1);
         maxWait--;
         gpsText.text = "Initializing GPS: " + maxWait.ToString ();
     }
     // Service didn't initialize in 20 seconds
     if (maxWait <= 0) 
     {
         gpsText.text = "ERROR: GPS Timed out, cannot continue";
         yield break;
     }
     // Connection has failed
     if (Input.location.status == LocationServiceStatus.Failed) 
     {
         gpsText.text = "ERROR: Unable to determine device location, cannot continue";
         yield break;
     }
     // Access granted and location value could be retrieved
     else
     {
         //gpsText.text = "GPS enabled and started";
         lat = Input.location.lastData.latitude;
         lon = Input.location.lastData.longitude;
         gpsText.text = "GPS: " + lat.ToString() + ", " + lon.ToString();
         yield break;
     }
         
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by brklemz · Jun 28, 2017 at 11:49 PM

Found it, works like a champ. With a little more digging, here it is:

Answer by _Paulius · Nov 21, 2016 at 01:44 PM Starting from iOS 10 Apple requires to set the 'NSLocationWhenInUseUsageDescription' field in App's info.plist file when location services are used (same for Camera & Microphone). You can set it in iOS Player Settings 'Location Usage Description'.

You should get warnings both when building the project in Unity & in Xcode if location services are used, but the description is not set.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

FMOD failed to initialize ... Error initializing output device. 2 Answers

Input.location.start always times out 1 Answer

GPS location string 0 Answers

input.location not updating on Iphone 0 Answers

Initialising List array for use in a custom Editor 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges