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!

pnuts
  • 58,317
  • 11
  • 87
  • 139
eozzy
  • 66,048
  • 104
  • 272
  • 428
  • I've not used this but the code looks interesting enough.. [iTellAFriend on guthub](https://github.com/aporat/iTellAFriend) – iOSDevil Aug 21 '12 at 12:20

3 Answers3

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.

A.Rod
  • 390
  • 4
  • 9
  • 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 Apr 02 '12 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 – Kashif Hisam Jun 21 '12 at 07:07
  • 4
    This link generates an error: "this feature no longer supported". Any updates for iOS 7? – Justin Whitney Feb 18 '14 at 04:02
  • @JustinWhitney Unfortunately not working anymore: https://stackoverflow.com/questions/23545736/send-gift-from-ios-app – Betty St Nov 06 '22 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.

Greg C
  • 889
  • 8
  • 6
  • can you directly redirect to the second url? – nishantcm Mar 09 '11 at 05: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 Mar 10 '11 at 23:41
  • do they also have a affiliate url in between? – nishantcm Mar 11 '11 at 07:48
  • 1
    They must have redirected because they did not know the AppleID for the app prior to submission – Abhinit Nov 22 '11 at 08: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 Nov 22 '11 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. – i_duhh_bomb Dec 08 '13 at 03:21
  • @i_duhh_bomb Unfortunately not working anymore: https://stackoverflow.com/questions/23545736/send-gift-from-ios-app – Betty St Nov 06 '22 at 17:14
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!

Seb OH
  • 785
  • 1
  • 6
  • 15