Run my app from when connected to a particular wifi : ios - ios

Many Wi-Fi hotspots these days have a "web login", especially free ones. You know, the ones that redirect any HTTP request to their login form.ios first connect to a wifi network then opens up the login page of the network where we fill our credentials and then it let us access the internet. Now I am creating a ios app that runs when connected to a particular network and instead of opening my browser the app takes user credentials once and automatically login for user and user can access the internet. Now how do I open my app whenever the user connects to the network and instead of opening up the app I would like it to show my app notification with the option of Login or Logout in the notification bar.
In android it appears like this:

You need to register a URL scheme within your app, and then configure your login page to call a certain URL containing the information you need. For example, if your app was called "Foobar", a valid URL might look like foobar://auth?user=jacobking&pass=password123. As I said, you will need to tell iOS that your app is listening for the foobar scheme. When iOS receives this URL, it will ask your app delegate if it can open it which you will answer through canOpenURL.
A detailed explaination and code examples can be found here.

Related

Is it possible to always allow "Open this page in WhatsApp" dialog on iOS Flutter App?

I'd like to launch Whatsapp from my Flutter app for a specific contact on the user's device. I'm able to do that successfully using url launcher as described in many questions on the subject (like this one this one).
The way it works, it opens an in-app web browser, which then prompts the user to open Whatsapp. On iOS, it then prompts the user with a dialog "Open this page in WhatsApp?"
Is there a way to always allow that? So that the user doesn't have to hit that each time they want to connect to someone on Whatsapp from my app?
Use the LaunchMode enum which is used to state the desired mode to launch a URL.
Future<bool> launchUrl(
Uri url,
{LaunchMode mode = LaunchMode.externalApplication}
);
LaunchMode.externalApplication is supported on all platforms. On iOS, this should be used in cases where sharing the cookies of the user's browser is important, such as SSO flows, since Safari View Controller does not share the browser's context.

How we can detect firewall or sonicwall redirect for our normal request in iOS devices ?

So here is the question
Many times you start your app and and your first API request fails and you realize that even though you're connected through internet You need to login in to Your office' or home network's firewall or sonicwall and login there
So you need to open safari and open your sonicwall page and login there and come back to our app and start it again.
I want my app to detect the same and show the the redirected html page in UIWebView and once the authintication finishes i want to execute the original request withing my app
My question is
1> Is it possible ?
2> If yes how can i achieve it ?
I would suggest using the same captive portal probe URLs that Apple uses in iOS Safari, for maximum compatibility. If those URLs return 200, you shouldn't be behind a (good) captive portal, assuming I'm remembering the details correctly.
You can beef that up further by using reachability APIs to detect network changes, and probing that URL, along with Google's generate_204 URL. And in some places, you'll find Google blocked (China, IIRC), in which case you might also consider a URL with a known, predictable, machine-validateable value, such as Apple's root certificate URL. :-)
When the user signs in, you should get another reachability change event, at which point at least one of your captive portal probes will succeed, and you can reissue any outstanding requests.

Putting information into a newly installed app

I have to create an iOS app, which needs to know a referral code right after the installation. The code comes from an email or from a link in the browser. The goal is to make the app have the referral code no matter it is already installed on the user's device or it is being installed by the clicking of the link.
What I know already:
I have to register an URL scheme with my app, for example myapp://
I have to handle opening by this URL, recognizing the referrer code from it (myapp://refcode=123)
I have to have a web service, which detects (with JavaScript) if the user's device can handle my URL scheme or not (like this: https://stackoverflow.com/a/6599773/511878)
If the app is not installed, I can send the user to the App Store to download it, otherwise I can open the app by this URL and transfer the information into it
What I miss: How can I immediately call this URL after installation?
I was sure this is impossible to do until this morning, when I've found that Apple's TestFlight is doing exactly the same. I've got an email containing an invite to some app, clicked on the link, and because I did not have TestFlight installed on that device so far, it brought me to the App Store, where I clicked install. The device installed TestFlight app. After this I've clicked the Open button in the Store, which immediately showed the invite for me.
I think the solution can't be that it recognized me, and picket up the invite from the server based on my user account, because I might have multiple invites, so it had to know which exact one to show.
EDIT: Video of this happening: http://gk.lka.hu/x/tf.mov
So the question is: How can I transfer information into an app which is being installed after a link is clicked without reclicking the link?
I'm a developer at Branch and we recently built this system for others to use. If you want to build a similar system from scratch, here is an example of what you'll have to do:
The web service you described above must capture some information from the user, such as IP address, OS, OS version, screen size, etc., before redirecting to the App Store. It should associate this with the link that was clicked, or at least the refcode from the link (http://yoursite.com/redirect?refcode=123).
After your app is downloaded, the first time it opens, send up the same info (IP Address, OS, etc.) up to your server. If your server sees these params and that they're the same as what you grabbed in step 1, it should pass back refcode=123 to your app.
Your app should then handle the 123 refcode however you see fit (e.g. open to the appropriate view controller, apply the referral code, etc.).
Hopefully that helps. It's definitely harder than it sounds to build from scratch..

How do I create a custom url scheme that will be recognized as a link?

My url scheme looks like "foo://".
This works great when I type into the browser.
The application requires I send this link in an e-mail and the e-mail opens from there. How can I configure the url scheme to be recognized as a link? I tried doing http://foo:// but of course my browser caught that.
One solution is to ping my server http://foo.com/redirect_to_app. If there is a way to do this with the app only I would like to know.
If you put the URL as foo:// in the email body, then that is all you need to do. Of course it requires that the user reads the email using the Mail app on their iOS device and the user must have your app installed on their iOS device as well.
Your foo:// URL will mean nothing if the email is read on a non-iOS device or computer or if the user doesn't have your app installed.
This all assumes that your goal is for one user of your app to send an email to another user of your app and tapping on the link in the email will launch your app on the receiver's iOS device.
There is a way. You need to create a webpage and create redirect code(url scheme) to your app.
Check this out... Check if URL scheme is supported in javascript

iOS Facebook switches back to app between login & permissions

I'm trying to setup my app to publish a simple post to a user's Facebook feed (image url, link, description). They don't need to use Facebook for anything else so the first time they click "Share" it needs to authorize the app, and the publish permissions.
If they have their credentials stored in the device as of iOS 6 they simply get two alert boxes and it's done with. But if they don't, or have an older version, it switches out to Safari for login. My problem is that it is then switching the user back to my app, then immediately back again to Safari to accept the publish permission. It's very jarring and unprofessional.
What I would like is for the page in Safari to change after the login to the permissions page so they can accept it, and THEN switch back to my app. I know this can be done because the popular Mixology app does exactly this behavior. Unfortunately Facebook keeps changing their SDK and all the information I find online is outdated.
I wrote up a solution here: FacebookSDK presents login UI twice to avoid the double switch.
Basically, you can use openActiveSessionWithPublishPermissions: to do what you want. However, you have to handle the special case where the user has signed in to Facebook from the device settings, which requires requests for read and publish permissions into two separate calls.

Resources