How to Add a Link for a Rate Button with Swift

How can I add a link for a rate button with swift?

Try This, change appId in your method by your App ID

Swift 5

import StoreKit

func rateApp() {
if #available(iOS 10.3, *) {
SKStoreReviewController.requestReview()

} else if let url = URL(string: "itms-apps://itunes.apple.com/app/" + "appId") {
if #available(iOS 10, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)

} else {
UIApplication.shared.openURL(url)
}
}
}

Swift 3 \ 4

func rateApp() {
guard let url = URL(string: "itms-apps://itunes.apple.com/app/" + "appId") else {
return
}
if #available(iOS 10, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)

} else {
UIApplication.shared.openURL(url)
}
}

id959379869 This is the id when you go on your Itune page of your app

Example :
https://itunes.apple.com/fr/app/hipster-moustache/id959379869?mt=8

How get the ID :

  1. Itunesconnect account
  2. My Apps
  3. Click on "+" Button
  4. New iOS App
  5. Fill require details
  6. After filling all details goto your App
  7. Click on More Button
  8. View on AppStore
  9. It will redirect you to your App URL this will be universal
  10. Look Http URL

App store link for rate/review this app

For versions lower than iOS 7 use the old one:

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

This works on my end (Xcode 5 - iOS 7 - Device!):

itms-apps://itunes.apple.com/app/idYOUR_APP_ID

For iOS 8 or later:

itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=YOUR_APP_ID&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software

Code snippet (you can just copy & paste it):

#define YOUR_APP_STORE_ID 545174222 //Change this one to your ID

static NSString *const iOS7AppStoreURLFormat = @"itms-apps://itunes.apple.com/app/id%d";
static NSString *const iOSAppStoreURLFormat = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d";

[NSURL URLWithString:[NSString stringWithFormat:([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f)? iOS7AppStoreURLFormat: iOSAppStoreURLFormat, YOUR_APP_STORE_ID]]; // Would contain the right link

Is It Possible To Add A Rate This App Link To My App?

The URL below is what you're looking for.
Just replace the 368754825 after id= with your app's Apple ID from iTunes Connect. This will take you right to the review page and won't have all the redirects like a normal link. Your App's Apple ID will not change between now and when it's on the store.

http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=368754825&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8

Update:
I tested the link I posted more than a year ago. It still works. The idea is that it won't work until your app is live. I know there's some concern about putting this link in and shipping before actually verifying it works, but it's the best option for having a review link in a 1.0. You can alternatively submit a 1.0.1 update (with link) right after 1.0 (without link) is approved which means you're only missing out on about a week's worth of reviews.

How to add a button (Rate my App on App Store) before publishing in App Store

Goto your itunesconnect account -> My Apps -> Click on "+" Button ->New iOS App -> Fill require details -> After filling all details goto your App -> Click on More Button -> View on AppStore -> it will redirect you to your App URL this will be universal & will be same after your app goes live

Open AppStore through button

Here. But I highly suggest you learn the basics of Swift!

UIApplication.sharedApplication().openURL(NSURL(string: "itms://itunes.apple.com/de/app/x-gift/id839686104?mt=8&uo=4")!)

If you wanna open the AppStore in Swift 5:

if let url = URL(string: "itms-apps://itunes.apple.com/app/id1629135515") {
UIApplication.shared.open(url)
}

How to link to apps on the app store

Edited on 2016-02-02

Starting from iOS 6 SKStoreProductViewController class was introduced. You can link an app without leaving your app. Code snippet in Swift 3.x/2.x and Objective-C is here.

A SKStoreProductViewController object presents a store that allows the
user to purchase other media from the App Store. For example, your app
might display the store to allow the user to purchase another app.


From News and Announcement For Apple Developers.

Drive Customers Directly to Your App
on the App Store with iTunes Links
With iTunes links you can provide your
customers with an easy way to access
your apps on the App Store directly
from your website or marketing
campaigns. Creating an iTunes link is
simple and can be made to direct
customers to either a single app, all
your apps, or to a specific app with
your company name specified.

To send customers to a specific
application:
http://itunes.com/apps/appname

To send
customers to a list of apps you have
on the App Store:
http://itunes.com/apps/developername

To send customers to a specific app
with your company name included in the
URL:
http://itunes.com/apps/developername/appname


Additional notes:

You can replace http:// with itms:// or itms-apps:// to avoid redirects.

Please note that itms:// will send the user to the iTunes store and itms-apps:// with send them to the App Store!

For info on naming, see Apple QA1633:

https://developer.apple.com/library/content/qa/qa1633/_index.html.

Edit (as of January 2015):

itunes.com/apps links should be updated to appstore.com/apps. See QA1633 above, which has been updated. A new QA1629 suggests these steps and code for launching the store from an app:

  1. Launch iTunes on your computer.
  2. Search for the item you want to link to.
  3. Right-click or control-click on the item's name in iTunes, then choose "Copy iTunes Store URL" from the pop-up menu.
  4. In your application, create an NSURL object with the copied iTunes URL, then pass this object to UIApplication' s openURL: method to open your item in the App Store.

Sample code:

NSString *iTunesLink = @"itms://itunes.apple.com/app/apple-store/id375380948?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

iOS10+:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink] options:@{} completionHandler:nil];

Swift 4.2

   let urlStr = "itms-apps://itunes.apple.com/app/apple-store/id375380948?mt=8"
if #available(iOS 10.0, *) {
UIApplication.shared.open(URL(string: urlStr)!, options: [:], completionHandler: nil)

} else {
UIApplication.shared.openURL(URL(string: urlStr)!)
}

Trigger an In-App Safari Browser from a PDF Button Widget with PDFKIT - IOS

You are missing few things in your current code. In your viewDidLoad method set the delegate of the pdfView

override func viewDidLoad() {
super.viewDidLoad()

if let documentURL = Bundle.main.url(forResource: "Application", withExtension: "pdf"),
let document = PDFDocument(url: documentURL),
let page = document.page(at: 0) {

// Set our document to the view, center it, and set a background color
pdfView?.document = document
pdfView?.autoScales = true
pdfView?.backgroundColor = UIColor.lightGray
self.insertLinkButtonInto(page)
//set the delegate of the pdfView to this viewController
pdfView?.delegate = self
}

Present the SFSafariViewController in delegate method with the url

func pdfViewWillClick(onLink sender: PDFView, with url: URL) {
print(url)
let sfVC = SFSafariViewController(url: url)
self.present(sfVC, animated: true)
}

set the action for PDFAnnotation in

 func insertLinkButtonInto(_ page: PDFPage) {

let pageBounds = page.bounds(for: .cropBox)

let linkButtonBounds = CGRect(x: 90, y: 10, width: 106, height: 32)
let linkButton = PDFAnnotation(bounds: linkButtonBounds, forType: PDFAnnotationSubtype(rawValue: PDFAnnotationSubtype.widget.rawValue), withProperties: nil)
linkButton.widgetFieldType = PDFAnnotationWidgetSubtype(rawValue: PDFAnnotationWidgetSubtype.button.rawValue)
linkButton.widgetControlType = .pushButtonControl
linkButton.caption = "Click link"
page.addAnnotation(linkButton)
let linkButtonAction = PDFActionURL(url: URL(string: "https://www.apple.com/")!)
//set the linkButton action
linkButton.action = linkButtonAction
}

Sample Image

Set rating right in the App (Swift 3, iOS 10.3)

It's one class function based on looking at the docs.

SKStore​Review​Controller.requestReview()

It also states you shouldn't call this function dependent on a user pressing a button or any other type of action because it is not guaranteed to be called. It would be a bad user experience if you indicate they are about to be shown a review modal and then nothing appears.

If you use this new option in your app it seems the best option is to just place it somewhere that won't interrupt any important actions being conducted by the user and let the framework do the work.

You can use criteria the user isn't aware of to choose when to call the function, i.e. launched the app x amount of times, used x number of days in a row, etc.

Edit: alternative

If you want to keep more control over the ability to request reviews you can continue the old way and append the following to your store URL to bring them directly to the review page.

action=write-review

guard let url = URL(string: "appstoreURLString&action=write-review") else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)


Related Topics



Leave a reply



Submit