Search code examples
iosactionscript-3apache-flexairitunes

Link for iOS app rating


I've been trying to direct users to the app store (iTunes) to rate my app. I can't get the right link. Users say that when they click the button, nothing happens.

This is the current link I'm using:

tms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=XXXXX

And in my code, which is for Adobe AIR, this is the line:

navigateToURL(new URLRequest("tms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=XXXXX"));

(Of course XXXXX is replaced with my App ID).

Appreciate any help. Thanks.


Solution

  • This is core objective-c code. Its very self-explanatory. All you need to do is to check whether the device is running iOS 7 or prior. In iOS 7, the URL for rating page is different.

    URL Format for iOS 7 or prior: itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=XXXXXXX

    URL Format for above iOS 7: itms-apps://itunes.apple.com/app/idXXXXXX

    In Objective-C, it looks like this:

    NSString *cAppleID = @"YOUR_APP_ID";
    NSString* iOS7AppStoreURLFormat = @"itms-apps://itunes.apple.com/app/id%@";
    NSString* iOSAppStoreURLFormat = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@";
    NSString* url = [[NSString alloc] initWithFormat: ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f) ? iOS7AppStoreURLFormat : iOSAppStoreURLFormat, cAppleID];
    [[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
    

    In AS3, it would look more like this (iOSVersion getter from How to determine the IOS version from within an Flex mobile app (AIR)):

    //Put in a Utils class
    public static function get iOSVersion():uint {
        var iosVersion:String = Capabilities.os.match( /([0-9]\.?){2,3}/ )[0];
        return Number( iosVersion.substr( 0, iosVersion.indexOf( "." ) ) );
    }
    
    
    
    var osVersion:Number = Utils.iOSVersion;
    var url:String;
    if (osVersion >= 7.0) {
        url = "itms-apps://itunes.apple.com/app/idXXXXXX";
    } else {
        url = "itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=XXXXXXX";
    }
    
    navigateToURL(new URLRequest(url));