"Gift App" from inside the app
Asked Answered
B

3

49

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!

Biflagellate answered 4/3, 2011 at 17:19 Comment(1)
I've not used this but the code looks interesting enough.. iTellAFriend on guthubQuickfreeze
R
35

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.

Resendez answered 4/3, 2011 at 21:31 Comment(7)
can you directly redirect to the second url?Soule
I don't see why not, as the link works if you click on it directly. I am curious though why Angry Birds chose to redirect to their site first and then to the app store. Perhaps they just want to see how many people are clicking the link in the app.Resendez
do they also have a affiliate url in between?Soule
They must have redirected because they did not know the AppleID for the app prior to submissionDaddylonglegs
Or perhaps they wanted a safe URL to use. If Apple changes the URL later on, it would require an app update to fix the application link. This way they can just fix it from the server side.Curiosa
@bashan , Whats the way to do this in iOS 7? Because when I try to click this link, it brings me to iTunes and says the feature is no longer available.Sofko
@Sofko Unfortunately not working anymore: https://mcmap.net/q/73116/-send-gift-from-ios-appFuel
W
38

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.

Waldheim answered 28/3, 2012 at 15:53 Comment(4)
Note that the URL begins with itms-appss:, with two letters "s" at the end. This is important--it wouldn't work for us any other way.Waldheim
Probably this is because, even in itunes the link only opens with https and not with normal http. So we have to use itms-appss and not normal itms-appsTroublesome
This link generates an error: "this feature no longer supported". Any updates for iOS 7?Gingrich
@JustinWhitney Unfortunately not working anymore: https://mcmap.net/q/73116/-send-gift-from-ios-appFuel
R
35

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.

Resendez answered 4/3, 2011 at 21:31 Comment(7)
can you directly redirect to the second url?Soule
I don't see why not, as the link works if you click on it directly. I am curious though why Angry Birds chose to redirect to their site first and then to the app store. Perhaps they just want to see how many people are clicking the link in the app.Resendez
do they also have a affiliate url in between?Soule
They must have redirected because they did not know the AppleID for the app prior to submissionDaddylonglegs
Or perhaps they wanted a safe URL to use. If Apple changes the URL later on, it would require an app update to fix the application link. This way they can just fix it from the server side.Curiosa
@bashan , Whats the way to do this in iOS 7? Because when I try to click this link, it brings me to iTunes and says the feature is no longer available.Sofko
@Sofko Unfortunately not working anymore: https://mcmap.net/q/73116/-send-gift-from-ios-appFuel
V
6

I have here some step-by-step instructions in how to add a 'Gift This App' button into your app:

  1. Add a button in your XIB and add an action to it.

  2. In your .m add the actions brackets e.g:

    -(IBAction)actionName {
    
    } 
    
  3. 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!

Viridity answered 3/9, 2011 at 8:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.