Trouble Returning to App from External App - ios

I'm building an app where the user can open the IMDB app to a particular actor or visit that page via Safari if they don't have the IMDB app installed.
NSString *imdbWebLink = #"http://www.imdb.com/name/nm1090683/";
NSString *imdbAppLink = #"imdb:///name/nm1090683";
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:imdbAppLink]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:imdbAppLink];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:imdbWebLink];
}
The above code works fine but I would like the IMDB App back button to return the user to my app. So I set up a URL type (named bundle identifier) and a custom URL scheme (named bundle identifier with the periods removed) in info.plist for the app. I then modified imdbAppLink following x-callback-url protocol:
imdbAppLink = #"imdb://x-callback-url/name/nm1090683/?x-success=custom_url_scheme&x-source=AppName";
The IMDB app opens correctly to the requested page but the Back button takes the user to the IMDB home screen and not to my app.
I've been researching this for hours here on Stack and on Google to no avail, yet lots of interesting dead ends. As Princess Leia once said, "Help me, Obi-Wan Kenobi; you're my only hope."
If you visit the imdb link above, you will see some of my non-iPhone work, but suffice is to say that I would prefer for the user to return directly to the app rather than indirectly with a bunch of Home button clicks.
Thank you in advance for any help.

X-callback-url has to be implemented in the app that you're opening, otherwise it will not work.
Do you have any reason to believe that IMDB supports it? I don't see IMDB listed at http://x-callback-url.com/apps/.

Related

How to open ios app using url?

I want to open my ios app using URL schemes. I am able to open app using this.
But I want if app is not installed then app store should be opened where user can download app.
Is this possible? How can I do that?
EDIT
Explaining question step wise:
I have a mail in my inbox with a url.
I click on URL then
i. If app is installed in phone, app will launch.
ii. Otherwise app store will be opened to download app.
Thank
I handled it via my server side code:
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("com.myapp://");
setTimeout(function() {
if (!document.webkitHidden) {
location.replace("https://itunes.apple.com/app/xxxxxxxx");
}
}, 25);}
else if ((navigator.userAgent.match(/android/i)) || (navigator.userAgent.match(/Android/i))) {
location.replace("https://play.google.com/store/apps/details?id=packagename&hl=en");}
else {
location.replace("http://www.example.com");}
I put this in my www.mysite.com/download page & share this url via campaigns.
What you're describing is called Deferred Deep Linking (Deep Linking refers to using a link to open your app, even directly to a specific piece of content, and Deferred means that it works even if the app isn't installed first).
Unfortunately there's no native way to accomplish this yet on either iOS or Android. URL schemes don't work, because they always fail if the app isn't installed. Apple's new Universal Links in iOS 9 get closer, but you'd still have to handle redirecting the user from your website to the App Store
A free service like Branch.io (full disclosure: they're so awesome I work with them) can handle all of this for you though. Here's the docs page covering exactly how to create email links like you described: https://dev.branch.io/features/email-campaigns/overview/
If your App is not installed in device then, you can open app store using below lines of code:
NSString *iTunesUrlofApp = #"itms://itunes.apple.com/us/app/apple-store/...";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesUrlofApp]];
Try below code:
if([[UIApplication sharedApplication] canOpenURL:url]){
// Means your app is installed, and it can be open
[[UIApplication sharedApplication] openURL:url];
}
else{
//Your app is not installed so, Open app store with your apps iTunes Url
NSString *iTunesUrlofApp = #"itms://itunes.apple.com/us/app/apple-store/...";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesUrlofApp]];
}
After iOS 5 you can also use https:// to avoid redirections.
Edit:
Check the link to open app from url if installed: Universal links to open app from Url.

How to open a background App using a silent push from a website button

Is it possible to use a web based API push service like "Boxcar" linked to a button in my webpage, to send a silent push to my iphone in which the iphone will interrupt the currently running app, and reopen (previously opened/in background) the linked app with the push's updated info?
So in all: open an app, go to another app (such as twitter), then on my webpage press a button and have twitter interrupted and brought back to the original app with updated data from the push.
Another question would be, do I need a 3rd party API to accomplish this? or can i use purely apple code?
I am a fairly new programmer and very new to APN's and app building, so any help would be greatly appreciated. Thanks!
First off, welcome to SO!
Unfortunately, there is no way to open up applications from the background programmatically in iOS. Apple leaves that to the user. You would have to send a push to the phone that the user interacts with in order to open up the app to a specific page. The only way you can open up another app is using URL Schemes (see here: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html)
The problem with that is you can only do it from YOUR app to someone else's app (or if you have a widely enough used app, some people might even link to yours, although I'm not sure Twitter would ever do that).
Basically what URL Schemes do is allow the phone to open up a URL as if it were a website. Before it loads the webpage, it checks to see if any apps respond to that URL. For instance, if you wanted to open Maps to a specific location:
NSString *title = #"title";
float latitude = 35.4634;
float longitude = 9.43425;
int zoom = 13;
NSString *stringURL = [NSString stringWithFormat:#"http://maps.google.com/maps?q=%##%1.6f,%1.6f&z=%d", title, latitude, longitude, zoom];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
Hope that answers your question!

iPhone App: Launch My App on My Website and Tips

I hope this is not asked before, I've searched and not sure those are the answers that I want (iPhone apps: Can I open an app from a link in a website? and Apple URL Schemes). Plus I haven't developed my website yet either, so I'll probably need some tips for that too.
My goal is to develop a website AND an iphone app that can eventually connect together. For example, something like Yelp or YouTube: you can go to their website on phone and they will tell you that either you can download their app or you can launch their app from there. Also IF they launch the app, the app will be displaying whatever they were looking at (maybe the same page, etc.)
So my questions are:
1) Can you give me suggestions regarding the development flow? (App first or website first, framework, etc.)
2) How do you actually connect them and make your app to go to the correct view?
Thanks a ton!
1) Can you give me suggestions regarding the development flow? (App
first or website first, framework, etc.)
I recommend you start with what you do best, so you're more productive. Unfortunately I have no site hint to give you, sorry.
2) How do you actually connect them and make your app to go to the
correct view?
You can use this for open any website:
NSURL * URLMyWebSite = [NSURL URLWithString:#"http://www.google.com"];
[[UIApplication sharedApplication] openURL:URLMyWebSite];
For open your app, you need enable URL Scheme, only add URL Type into plist:
After this, you can open your app:
Open My First App
And you can send parameter:
Open My First App
Use HelperLibrary for parse query string into NSDictionary.
Other app can open your app:
NSURL * URLMyFirstApp = [NSURL URLWithString:#"myfirstApp://login?username=rondinellimorais&password=1234"];
if([[UIApplication sharedApplication] canOpenURL:URLMyFirstApp]){
[[UIApplication sharedApplication] openURL:URLMyFirstApp];
}

"Gift App" from inside the app

I noticed that on the latest angry birds update they added a feature to gift your app from inside the app.
Up till now I knew you can gift paid apps from the iTunes itself. Does anybody know what link should I use to access this mechanism from inside the app itself?
Thanks!
Actually, you'll want your URL to start with itms-appss: if you want it to open in the App Store app, where someone would actually gift an app. This feels more natural than Safari popping up.
// example app id for batman arkham city lockdown
#define APP_ID 459850726
NSString *GiftAppURL = [NSString stringWithFormat:#"itms-appss://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/giftSongsWizard?gift=1&salableAdamId=%d&productType=C&pricingParameter=STDQ&mt=8&ign-mscache=1",
APP_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:GiftAppURL]];
APP_ID should obviously be defined to the Apple ID of your app.
Also worth noting, the URL is case sensitive.
If you watch what happens when you click that button, you can see that it initially makes a request to a redirect script on www.angrybirds.com:
http://www.angrybirds.com/redirect.php?device=iphone&product=angrybirds&type=purchasegift
From there you are redirected to a secure url of the form:
https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/giftSongsWizard?gift=1&salableAdamId=343200656&productType=C&pricingParameter=STDQ
343200656 is the AppleID for Angry Birds.
I have here some step-by-step instructions in how to add a 'Gift This App' button into your app:
Add a button in your XIB and add an action to it.
In your .m add the actions brackets e.g:
-(IBAction)actionName {
}
add this code in and replace APP_ID with the number in the apps web page link for e.g.
itunes.apple.com/au/app/[APPNAME]/id**APP_ID**?mt=8
this is a code e.g:
- (IBAction)actionName
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/giftSongsWizard?gift=1&salableAdamId=**[APP_ID]**&productType=C&pricingParameter=STDQ"]];
}
Hope this helps!

In-App review feature in iPhone App

I have recently seen in some Apps that review and rating (with 5 stars) can be integrated into the app. Does anyone have an idea how this is done? e.g. with a http request?
More specific: Can I create a view in my App with a UITextField and a Button, so that when the user writes his review in the textfield and click send, the review should be posted to the "Customer Reviews" in the App Store? and the rating should also be done inside the App similarly.
Yes, I did this with my own app. I have a rating button that hits the following method on click:
- (IBAction) reviewPressed: (id) source {
NSString *str = #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=341086403";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
You will need to replace the ID in the URL with your own App ID. For new apps, this presents you with a chick-and-egg problem - you don't have an ID until the App goes live.
You can get your application ID by going in the process of submitting an app but choose to upload the app binary later. You will then get the app ID and thus add it in your code.
I think its late but this is the best solution.
You can use below url to directly send user to write a review page on App Store. Just need to replace application id.
itms-apps://itunes.apple.com/gb/app/id1136613532?action=write-review&mt=8
Example :
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"itms-apps://itunes.apple.com/gb/app/id1136613532?action=write-review&mt=8"]];
Here My Application Id is 1136613532. You can replace it with yours.
Tested in iOS 10.3

Resources