iOS Settings Bundle - How should text inputs be validated? - ios

I'm creating a settings bundle for my app to allow users to set their default application server. How should I be validating the user input for a Text Field in the settings?
I've found this post from 6 years ago, and also have read through the apple docs and realize there is no mention of input validation.

There is no way to do input validation for stuff in settings.bundle while the user is typing. You'll need to do this when your app starts, and/or in response to the UserDefaults.didChangeNotification notification, and there's no really good way to provide user feedback.
That said, there are 3rd party libraries out there that allow you to move this stuff from the system's settings app into your app directly, making it much more easy to access, and also allow a high degree of customisation, in particular https://github.com/futuretap/InAppSettingsKit.

Related

How do I implement deferred deep linking in an iOS app?

I want to implement deferred deep linking in my iOS app as a means of tracking referrals. When a user of my app wants to refer a friend, I'll generate a URL that has a unique referral code. When the other person receives the link and opens it, I want it to take them to my app's page in the App Store. Then if they install my app, when it first opens, I need a way for it to read the referral code from the original URL.
I've found may pages about deferred deep linking on the web but none that really explain how to do it. Instead, these pages all end up telling you to install some third-party code or use some commercial service. This isn't what I'm after. I want to learn how to do this myself.
There are lots of old pages out there that recommend convoluted and error-prone solutions, like tracking the user's IP address, putting the referral code into the clipboard, or somehow obtaining it from a cookie in a web view. I don't think these are the correct solutions to be using in 2022.
If anyone can recommend the appropriate resource, I'd appreciate it.
If it is the case that Apple simply doesn't want us to do this and doesn't provide any support for it, then I'd like to know that too. I was under the impression that they did, but maybe I'm wrong.
Thanks,
Frank
Apple's Universal Links allow for this (would understand the difference between the typical URL Scheme and Universal Links as threshold). This assumes you're willing to do some lifting server-side along with other hurdles on the iOS side, largely administrative.
A benefit of Universal Links and the server-side work is that you're provided a fallback webpage if a user does not have the app installed. Since the app should open if downloaded, you could typically just redirect to the app store from this URL. In this case, though, before any redirects, you could execute an operation to decode the unique params passed in the URL and persist it in a remote data store. The data encoded needs to be required and verifiably unique during your registration -- email seems ideal.
If that's feasible, your standard registration flow could require email verification with a link to the app as a mandatory entry point (think slack magic link). When the user submits his/her email to verify, you could first check that email against your data store to see if it maps to any previously decoded referrals saved from the flow above. If so, you could generate a unique link for this email to your app with params that will direct the deferred/deep link.
The good news is, I found a solution. I could construct a web page that redirects the user to the app store, but before doing so, copies some text into their clipboard (without telling them or asking them to do anything). Then later if they install my app I can get the text by pasting from the clipboard. I tested this idea and it works.
The bad news is, starting with iOS 16, Apple now asks you for permission to paste. So if you try to do this, your user will launch your app and immediately get promoted with a message asking them to allow a paste from Safari. I expect most users will deny the request and just the fact that they saw it will erode their trust in the app (I know I wouldn't trust an app that tried consume my clipboard without a direct command from me).

Is it possible to get info on other installed iOS apps?

Is it possible to read the contents of another application installed on an iPhone? What about from an extension or keyboard?
I'm trying to come up with something that 'checks' other apps to see if they have any deep links (like Twitter's Twitter://timeline that takes users straight to the timeline in the Twitter app).
Is there any smart way to check a given app for deep links?
Is it even possible to peek at another app's contents from within my app? I suspect no.
If no, what about making a keyboard or extension of some sort that I can access from an app like Twitter and see its contents, such as a URL deep link?
You don't have much options, you may use -canOpenURL:, but, since iOS9, must include special credentails listing all the custom schemes you want to check.
You can't read other app's contents on a non-rooted device unless this app is sharing a keychain (so it can exchange data via the shared keychain). The same thing goes with extensions.
iOS has some high bars on security, so, don't expect much or even, anything.
Something you may want is IntentKit. Also there are ideas around the web about standard url query format like MobileDeepLinking.

Can I find out the location of an app's icon on the home screen?

Is is possible to dynamically figure out the position of an app's icon on the home screen of an iphone/ipad?
Sorry I don't have enough credit to comment yet so I'm posting here.
To my knowledge no you cannot natively or easily do this. I know of no open source or other libraries. The reason being that your app exists in its own world, it is not in touch per say with the rest of the device. It can get permissions to read and write data but it doesn't know of itself.
Does that make sense?
When you open a website it cannot know which tab it is in the browser. Instead it knows how it was accessed and what device (physically) is using it. It knows the user-agent, the time, the browser, etc because that is information sent to it in the request. In turn the phone on launch gives data to the app in how to handle it but not for example how many other apps are running, or where it is on the screen. It's not normally considered relevant to run time. In addition it's a security feature in preventing an app from deleting or altering other apps, as well as itself. If you have an iPhone you will notice that SIRI cannot turn off google maps navigation or any other non-apple specific app. Only apps natively comparable and private party ones (ex apples) are accessible because Apple did that intentionally. They all know of their own existence and each others. However non-native in the sense of apps that do not come preinstalled and manufactured by the company creating the device are less trustworthy, in addition there are no guarantees about how they will be run by the device, where they will be, or what other apps will be there.
It is true that an app can request for another app it may be comparable with but it is up the user to handle that information.
May I ask for curiosities sake why you are trying to do this? Are there any other workarounds?
However in terms of it being physically possible, yes. I doubt that apple allows independent developers to do this however. But an example of this occurring may be gridlock where a user can move their apps around differently on the screen. The app in this case has the ability to access app position. But I believe in this case app position is about the UI and not about nested files. apps cannot to my knowledge modify information outside of their own file. Imagine if you had an app that could edit other games scores.
It is not possible to dynamically find out the position of an app's icon on the Home Screen (even for jailbreak apps). Apple wants you to respect the user's privacy settings.
Extra Info - There is popular JavaScript library that adds a promo bubble to the bottom of your mobile web application, inviting users to bookmark the app to their device's home screen.

Is it possible to use Settings App to store preferences from external sensors like the Nike+iPod App?

Perhaps it is a silly question but I want to be sure about it.
I am developing an app which uses a pulsometer and I am interested in letting the user set the pulsometer which is going to be used in the app (each pulsometer has an unique ID).
As the pulsometer identifier is something that will be hardlyever changed (but it could be changed) Settings App would be the right place to manage that info.
I know I can use NSUserDefaults in a dictionary way to store values, but I don't want the user manually write the identifier code of the sensor in the Settings App. I want to detect the sensor from the app. I know how do that in my App, but is there any way to do it in the Settings App?
I think it is not possible because it requires including code for executing in the Settings App, but I don't know if it is a way to do it ("linking" the userdefaults with that code or something like that).
For example, the Nike + iPod App lets you detect the sensor in the way I want in the Settings App.
Can anybody confirm that it is not possible (of course, without being Nike and making an agreement with Apple to have the option included in Settings App XD)?
You can set up options for your own app "Settings" pane by using display options based on the pulsometer as soon as you startup your application. Your app would have to detect it when running (and determine the range/steps). After that, the user could change a pulldown/stepper in the settings pane from your app. If I understand you correctly.

How to Update an Application After Users Pay For Upgrade

I need to update my application after the user pays for an update. I want to alter the current application instead of downloading a new version. After the user pays, I will enable certain functions of the app.
How would I implement this?
You can't update the code or app bundle in any way. You can download resources or modify configuration files, however. So all features need to exist, but may be disabled. For something like a game you could download some more levels upon purchase.
Apple will not allow an app that has visible but unusable features. You can't show a grayed out feature and say, "pay us to get this feature." Neither will they let you significantly alter an app without changing its name. Instead they force you to issue a lite version with the option to upgrade to a full and/or pro versions. They do this both to protect the user and to protect their revenues from the app store.
A really good way to determine if Apple will let you do something is to ask, "Does Apple stand to lose money if I do this?" If the answer is yes, then chances are very good your idea won't fly.
Also, remember that the app store has a rule that once a user pays for an app, they automatically receive all future versions of the app free of charge. You can't force users to pay for upgrades the way you can on conventional platforms.
Having said that, since you can't run another process to upgrade your app on the iPhone, I think the only way to upgrade an existing app without replacing it would be to use some kind of modular plug-in architecture in which you download plug-ins that add more features. Objective-C makes it ridiculously easy to implement plug-ings.
You can't update on the go your application.
You need to put some kind of boolean switch value in a config file. (or with a server handshake)

Resources