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!

1

3 Answers 3

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.

4
  • 1
    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.
    – A.Rod
    Commented Apr 2, 2012 at 14:56
  • 2
    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-apps Commented Jun 21, 2012 at 7:07
  • 4
    This link generates an error: "this feature no longer supported". Any updates for iOS 7? Commented Feb 18, 2014 at 4:02
  • @JustinWhitney Unfortunately not working anymore: stackoverflow.com/questions/23545736/send-gift-from-ios-app
    – Betty St
    Commented Nov 6, 2022 at 17:11
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.

7
  • can you directly redirect to the second url?
    – nishantcm
    Commented Mar 9, 2011 at 5:41
  • 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.
    – Greg C
    Commented Mar 10, 2011 at 23:41
  • 1
    They must have redirected because they did not know the AppleID for the app prior to submission
    – Abhinit
    Commented Nov 22, 2011 at 8:10
  • 7
    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.
    – jpm
    Commented Nov 22, 2011 at 14:52
  • 5
    @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. Commented Dec 8, 2013 at 3:21
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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.