iPhone Objective-C: Ensure user allows location sharing before doing other actions - iphone

My application asks for location at the log in screen, and right now, the user can log in without sharing his or her location. When the user selects "No" for sharing location, an error that reads Error Domain=kCLErrorDomainCode=1 "The operation couldn't be completed. (kCLErrorDomain error 1.)" is thrown. I'm guessing that's because I am trying to access latitude and longitude without having such things.
My question is, how do I make sure that a user allows location before anything else can be done? Is there a way to create a new "Allow Location" pop-up request?
Thanks in advance!

You would need to implement locationManager:didFailWithError.
The documentation states that:
If the user denies your application’s
use of the location service, this
method reports a kCLErrorDenied
error. Upon receiving such an error,
you should stop the location service.
Additional information is here

My suggestion would be have your application cope with the situation where no location information is available, by informing the user that this is a requirement etc.
Repeating the dialog until you get the answer you want is just going to annoy the user.

Related

Google action. UI is not updated when report state change

I am trying to build a custom google action.
When my device is changing state (for example the user is turning the light on).I am updating the graph database to let the device know that a change happened.
The ReportState call works correctly (I get an HTTP 200 code). When I ask the google assistant for the device state, it gives me the correct information.
But the UI in Google home is not changing.
I read somewhere that is the way it works. Just like to have a confirmation on that, as it will confuse a lot of users...
This is the current behavior in the user interface. If you're receiving a 200 status code, you're doing it correctly.

How to call Web service Continuously in ios

I have an ios app.
In which i have multi user account.So multiple user can Login.
When one user see other user profile and if that user is also online i want to notify him.
I can't get how to implement it.
If i have to continuously check some flag value on server if someone has checked their profile or how can i handle it?
Remote notifications is the way to do it. The logic on when and who has to be notified can be handled at the server.
You may have seen lots of apps asking for permissions to send notification. The downside being if the user denies that permission.
Polling from client side can also be one of the methods which can be used and but would require the client to do most of the computation.
So all in all, its a call you got to take considering what you are building.

Remove Location Manager alert from my application

I used Location Manager API for find out Latitude and Longitude of the current place.
But when i called update location manager method i get some alert from application which i have attach along this message.
I want to remove this alert message and by default i want to set YES or (Allow) for that.
Is it possible or not?
Thank You
Its not possible to do that. It is done to safeguard user's security. If you've been following the PATH ADDRESSBOOK issues, it was raised 'coz Path App didn't ask users before using their Address Book. So Apple's implemented the asking feature or permission by default in Core Location and Push Notifications. And By the looks of it, in the address book as well and you will have to stick to it - After all, you don't want to fall into privacy issues. :)
It is not possible,This dialog would be shown once when the app starts
You cannot and even if you could, probably your App wouldn't be accepted by Apple.

Managing absence of current location

I am new to the objective C programming and I am in a position where I need to create an iPhone App really quickly. I am using XCode 4.2
I have found a method to get the user country (using NSLocale)
I assume that the application will ask the user if he wants to use his/her current location for that?
if the user says "don t allow" how can we manage that , what are the functions that can be used ?
Thanks
The Core Location methods automatically handles user permission, if that's what you're asking. If the user says he doesn't want his location to be used, well, handle it the way you want : display an error message, of it is crucial to your app, display an alert saying how location is crucial to your app, and exit it. Or something else, it's up to you.
You can check if the location services are enabled system-wise with [CLLocationManager locationServicesEnabled]. For your app only, when getting the location fails, the - locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error message is sent to the location managed delegate. You can check the error domain/code to have more details

How to obtain ongoing user consent for use of location info

In my application, I'm using location information to capture the user locations.
I have the following questions:
What are the alert messages we have to provide in the application for user to show that we are going to use their location?
Can we fetch the location info in the background once the user accept that?
If user is allowed to fetch the location information let's say in the first time the application launches, do we need to provide the alerts for consecutive fetches (in next app loads)?
Thank you.
None, iOS will do this automatically.
This is the normal procedure.
iOS will bug the user as it is programmed to do.
If you assign the purpose property to your location manager instance, it will include that in the popup that asks the user for permission. See http://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/doc/uid/TP40007125-CH3-SW30
Yes for the other two.
I'm not an iPhone programmer, but I'm an iPhone user. Every time an application has asked for access to my location information, once I say yes it never asks again and regularly uses it.
This leads me to believe that the answer to your questions is:
1) Probably the alert message is provided automatically the first time your application requests location information. I'm pretty sure they aren't relying on developers policing themselves.
2) Yes, I believe so.
3) Yes, I believe so.