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!
Related
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.
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/.
some basic questions for a very basic app:
For the first time when the app runs, the user is presented with a screen where an ID (number) has to be selected. This ID is then embedded in a URL that is used when launching Safari as the user is pushes a Start button. The ID is stored in the user preferences.
The second time the app is launched, I just want to read out the ID from user preferences and launch Safari, without the user seeing the ID screen or pushing any buttons.
The first scenario I got working by reading out the ID in viewDidLoad etc.
For the second scenario I'm pretty much clueless. Where should that code be placed. Is it technically possible? Would Apple accept this?
Yes, It's possible. And why Apple would not accept this? Just use this code:
[[UIApplication sharedApplication] openURL:url];
url - your composed URL with user ID.
Is it possible to retrieve the name of the app which will handle a specific URL?
In other apps I saw "Open Link in Safari" and if you click, YouTube or whatever else will launch. I don't really like this behavior and I'd like the get the corresponding app name before calling
[[UIApplication sharedApplication] openURL:[NSURL someURL]];
to set the right button title.
No, that's not possible with the official SDK.
If you really want that you could create a file/database with the most common URL schemes on iOS (check this), then ship your app with it.
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