How to read iPhone preferences from native application - iphone

Is there any way I can read settings for iPhone preferences. I wanted to read whether the push notification flag is on or not. Based on this setting, I wanted to take some action in my native application. Please guide.

You can read settings for your application using NSUserDefaults. If you are asking if you can read whether push notifications are on globally, then no, I don't think you can. If your application asks to use them, it will ask the user if they want to turn them back on, but that is all you can do.

Related

How can Apple Watch listen to data change on iPhone?

Let's say the iPhone has a text field or any internal data, upon the data change, I want to push it automatically to the Apple Watch. I know I can use the share data. But that seems to require user to initiate the call (e.g. pressing a button) on the Watch. Is there a listener on the Apple Watch that I can use if there is a change in the shared data? Or there is way for the iPhone to automatically push data to the watch, and the watch just receive it and display it? Or any other way?
You can see this answer. MMWormhole seems a good way to communicate between App and its extensions (i.e. Watch App).
Hope this helped.

How can I block custom applications using URL schemes in iPhone?

I have worked a bit with URL schemes and have managed to access a custom app that i created using another app. My requirement is to block my custom apps once the battery level goes less than a certain level.
Is there any way to do that? What data will I have to pass through the URL scheme?
By block i mean either disable or uninstall completely. Just seeking some control.
You cannot completely block your application from launching if it's being opened through URL scheme. I suggest checking whether your app is launched by opening a scheme and then just display an alert view with a notice that your app requires the phone to have more battery power (or be charging).
i think you should use push notification, it can handle your requirement

Alert for reminding the user to rate the app

As you may have seen in some apps an alert pops up asking the user to rate the app in itunes and usually the alternatives you get to choose from is something like: Sure which opens the rate page for the app. The second option is No Thanks which closes the alert and the third option usually is maybe later which displays the alert later.
I was wondering how to do this.
I want the alert to be displayed after say the app has launched 20 times if that would be possible.
And how can I create an maybe later alternative which displays the alert maybe 15 launches of the app later?
And a final question is there a special link for the apps rate page? So when you click the sure button or whatever it will take your directly to the rate page.
I've used this: https://github.com/arashpayan/appirater. You can look at my fork as well for a specific mod I needed.
[EDIT: comment re NSUserDefaults]
I suggested this link because it is a full, working implementation of what you describe that is easily integrated into existing apps. I've used (and modified) it myself. NSUserDefaults is a general purpose mechanism for persisting app state. I agree with the others that it's a very useful thing to learn and use, it's just not a full answer to your question. If you choose to roll your own implementation of a rating system (nothing wrong with that) you will most likely use NSUserDefaults to store the relevant info.
Check out my answer for this similar question. I provide two different links you can use for taking the user to the "rate this app" screen in the App Store.
Direct "rate in iTunes" link in my app?
You can use NSUserDefaults to save the launch count (increment it in application:didFinishLaunchingWithOptions:), then save the user's choice another preference key. If the user says later, you could reset the counter back to zero.
I don't think there is a special rating link, but you can link to your app's specific App Store page. This was incorrect, as TomSwift points out; see Direct "rate in iTunes" link in my app?
I wrote a library for doing this with minimal effort on your part:
https://github.com/nicklockwood/iRate
I'd recommend using a library rather than rolling your own solution. It may seem like a simple problem but the library takes care of a whole bunch of extra stuff, like ensuring that the user is prompted for each new installed version, that they are reminded after a certain time if they decline, that they aren't prompted to go to the app store unless they have a network connection, etc.

asking if user wants to use Location Services

How does the process of "asking if user wants to use Location Services" work?
I read here that a dialog at the installation appears, which asks the user if Location Services should be allowed or not. Does it mean that there is nothing to do for the developer, because the user can change this behavior in settings? So there is no "asking dialog" to implement and no storing in system settings? Does the app need a settings menu where this behavior can be changed?
What is if I want such a settings menu in my app?
The only thing the developer has to be aware of is to check in his code if it is allowed or not? See here.
Sounds reasonable isn't it ? Yes, that's it. No dialog to implement yourself, iOS manages that for you.
The user can change the settings in Settings/General/Location Service.

Possible to alert server to iphone settings change?

I'm working on giving our users context-specific PUSH notification settings, similar to what Facebook has in their settings menu.
As far as I can tell though, there's no way to actually notify our server of these changes until the user actually launches the app.
Is this correct? Is there any mechanism provided for immediately alerting our servers to a settings change?
That's correct: you can't detect changes made in the settings app until the next time your app launches.
The closest option to what you're describing would be to put the settings in your app somewhere and notify the server from there.