diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift index 8d2ff99..038569b 100644 --- a/Example/AppDelegate.swift +++ b/Example/AppDelegate.swift @@ -33,7 +33,7 @@ } } - let iPhoto = "497786065" // iPhoto iOS + let Pages = "361309726" // Pages iOS #elseif os(OSX) @@ -45,7 +45,7 @@ } - let iPhoto = "408981381" // iPhoto Mac + let Pages = "409201541" // Pages Mac #else #endif @@ -62,13 +62,13 @@ extension AppDelegate { // Normally, all the setup would be here. // But, because we are presenting a few different setups in the example, // The config will be in the view controllers - // Armchair.appID("408981381") // iPhoto + // Armchair.appID("408981381") // Pages // // It is always best to load Armchair as early as possible // because it needs to receive application life-cycle notifications // // NOTE: The appID call always has to go before any other Armchair calls - Armchair.appID(iPhoto) + Armchair.appID(Pages) Armchair.debugEnabled(true) } } diff --git a/Example/ViewController.swift b/Example/ViewController.swift index 9a78ab6..ec1ae3f 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -78,11 +78,16 @@ extension ViewController { resetAppReviewManager() // The AppID is the only required setup - Armchair.appID(iPhoto) + Armchair.appID(Pages) // Debug means that it will popup on the next available change Armchair.debugEnabled(true) +#if os(iOS) + // Explicitly disable the storeKit as the default may be true if on iOS 8 + Armchair.opensInStoreKit(false) +#endif + // true here means it is ok to show, but it doesn't matter because we have debug on. Armchair.userDidSignificantEvent(true) } @@ -91,7 +96,7 @@ extension ViewController { resetAppReviewManager() // The AppID is the only required setup - Armchair.appID(iPhoto) + Armchair.appID(Pages) // Debug means that it will popup on the next available change Armchair.debugEnabled(true) @@ -133,6 +138,11 @@ extension ViewController { // or you change the default title, message or button titles, set this to YES. Armchair.useMainAppBundleForLocalizations(true) + #if os(iOS) + // Explicitly disable the storeKit as the default may be true if on iOS 8 + Armchair.opensInStoreKit(false) + #endif + // This sets the Affiliate code you want to use, but is not required. Armchair.affiliateCode("11l7j9") @@ -180,12 +190,12 @@ extension ViewController { resetAppReviewManager() // The AppID is the only required setup - Armchair.appID(iPhoto) + Armchair.appID(Pages) // Debug means that it will popup on the next available change Armchair.debugEnabled(true) - // This overrides the default of NO and is iOS 6+. Instead of going to the review page in the App Store App, + // This overrides the default of NO in iOS 7. Instead of going to the review page in the App Store App, // the user goes to the main page of the app, in side of this app. Downsides are that it doesn't go directly to // reviews and doesn't take affiliate codes Armchair.opensInStoreKit(true) diff --git a/Source/Armchair.swift b/Source/Armchair.swift index 4ba9aea..b5d670e 100644 --- a/Source/Armchair.swift +++ b/Source/Armchair.swift @@ -1293,39 +1293,34 @@ public class Manager : ArmchairManager { userDefaultsObject?.synchronize() #if os(iOS) - // Use the in-app StoreKit view if set, available (iOS 6+) and imported This works in the simulator. + // Use the in-app StoreKit view if set, available (iOS 7+) and imported. This works in the simulator. if opensInStoreKit { let storeViewController = SKStoreProductViewController() - let appIDVal: Int? = appID.toInt() - if let appIDInt = appIDVal { - var productParameters: [NSObject:AnyObject]! = [SKStoreProductParameterITunesItemIdentifier : NSNumber(integer: appIDInt)] + var productParameters: [NSObject:AnyObject]! = [SKStoreProductParameterITunesItemIdentifier : appID] - if (operatingSystemVersion >= 8) { - productParameters[SKStoreProductParameterAffiliateToken] = affiliateCode - productParameters[SKStoreProductParameterCampaignToken] = affiliateCampaignCode + if (operatingSystemVersion >= 8) { + productParameters[SKStoreProductParameterAffiliateToken] = affiliateCode + productParameters[SKStoreProductParameterCampaignToken] = affiliateCampaignCode + } + + storeViewController.loadProductWithParameters(productParameters, completionBlock: nil) + storeViewController.delegate = self + + if let closure = willPresentModalViewClosure { + closure(usesAnimation) + } + + + if let rootController = getRootViewController() { + rootController.presentViewController(storeViewController, animated: usesAnimation) { + self.modalPanelOpen = true + + //Temporarily use a status bar to match the StoreKit view. + self.currentStatusBarStyle = UIApplication.sharedApplication().statusBarStyle + UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.Default, animated: self.usesAnimation) } - - storeViewController.loadProductWithParameters(productParameters, completionBlock: nil) - storeViewController.delegate = self - - if let closure = willPresentModalViewClosure { - closure(usesAnimation) - } - - - if let rootController = getRootViewController() { - rootController.presentViewController(storeViewController, animated: usesAnimation) { - self.modalPanelOpen = true - - //Temporarily use a status bar to match the StoreKit view. - self.currentStatusBarStyle = UIApplication.sharedApplication().statusBarStyle - UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.Default, animated: self.usesAnimation) - } - } - } else { - debugLog("Can't parse \(appID) into an Int for the SKStoreProductViewController") } //Use the standard openUrl method diff --git a/iOS Example.xcodeproj/project.pbxproj b/iOS Example.xcodeproj/project.pbxproj index 3f6cbf5..ea09860 100644 --- a/iOS Example.xcodeproj/project.pbxproj +++ b/iOS Example.xcodeproj/project.pbxproj @@ -9,7 +9,8 @@ /* Begin PBXBuildFile section */ E60FA81819C9219600179D70 /* logo.png in Resources */ = {isa = PBXBuildFile; fileRef = E60FA81719C9219600179D70 /* logo.png */; }; E6A0AFB419C9D30900C3A7DC /* Armchair.bundle in Resources */ = {isa = PBXBuildFile; fileRef = E6A0AFB319C9D24000C3A7DC /* Armchair.bundle */; }; - E6D8B8EC19C75559001AD043 /* Armchair.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E6D8B8BB19C7382B001AD043 /* Armchair.framework */; }; + E6D06B5B19CB413600DE5D11 /* Armchair.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E6D8B8BB19C7382B001AD043 /* Armchair.framework */; }; + E6D06B5C19CB413600DE5D11 /* Armchair.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E6D8B8BB19C7382B001AD043 /* Armchair.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; E6E5F4C319C8E18E008A6C1B /* armchair.jpg in Resources */ = {isa = PBXBuildFile; fileRef = E6E5F4C219C8E18E008A6C1B /* armchair.jpg */; }; E6E5F4CD19C8E388008A6C1B /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = E6E5F4CC19C8E388008A6C1B /* Icon.png */; }; E6E5F4CF19C8E3C6008A6C1B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E6E5F4CE19C8E3C6008A6C1B /* Images.xcassets */; }; @@ -33,7 +34,21 @@ remoteGlobalIDString = E6A0AF6519C9CFF400C3A7DC; remoteInfo = ArmchairLocalizable; }; - E6C9055D19C6433500F41311 /* PBXContainerItemProxy */ = { + E6D06B5519CB412500DE5D11 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = F8111E4E19A95D7C0040E7D1 /* Armchair.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = E6F6159419C9FFDA00C0B51C; + remoteInfo = ArmchairLocalizableMac; + }; + E6D06B5919CB412500DE5D11 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = F8111E4E19A95D7C0040E7D1 /* Armchair.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = F8111E3219A95C8B0040E7D1; + remoteInfo = Armchair; + }; + E6D06B5D19CB413600DE5D11 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = F8111E4E19A95D7C0040E7D1 /* Armchair.xcodeproj */; proxyType = 1; @@ -64,12 +79,13 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - E6C9055419C63AAF00F41311 /* Embed Frameworks */ = { + E6D06B5F19CB413600DE5D11 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 10; files = ( + E6D06B5C19CB413600DE5D11 /* Armchair.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -94,7 +110,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - E6D8B8EC19C75559001AD043 /* Armchair.framework in Frameworks */, + E6D06B5B19CB413600DE5D11 /* Armchair.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -107,6 +123,7 @@ E6D8B8BB19C7382B001AD043 /* Armchair.framework */, E6E5F4C119C8E156008A6C1B /* Armchair.framework */, E6A0AFB319C9D24000C3A7DC /* Armchair.bundle */, + E6D06B5619CB412500DE5D11 /* Armchair.bundle */, E6D8B8BD19C7382B001AD043 /* ArmchairTests.xctest */, ); name = Products; @@ -155,13 +172,14 @@ F8111E0119A951050040E7D1 /* Sources */, F8111E0219A951050040E7D1 /* Frameworks */, F8111E0319A951050040E7D1 /* Resources */, - E6C9055419C63AAF00F41311 /* Embed Frameworks */, + E6D06B5F19CB413600DE5D11 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( - E6C9055E19C6433500F41311 /* PBXTargetDependency */, E6A0AFB019C9D24000C3A7DC /* PBXTargetDependency */, + E6D06B5A19CB412500DE5D11 /* PBXTargetDependency */, + E6D06B5E19CB413600DE5D11 /* PBXTargetDependency */, ); name = "iOS Example"; productName = Armchair; @@ -213,6 +231,13 @@ remoteRef = E6A0AFB219C9D24000C3A7DC /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + E6D06B5619CB412500DE5D11 /* Armchair.bundle */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = Armchair.bundle; + remoteRef = E6D06B5519CB412500DE5D11 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; E6D8B8BB19C7382B001AD043 /* Armchair.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; @@ -270,10 +295,15 @@ name = ArmchairLocalizable; targetProxy = E6A0AFAF19C9D24000C3A7DC /* PBXContainerItemProxy */; }; - E6C9055E19C6433500F41311 /* PBXTargetDependency */ = { + E6D06B5A19CB412500DE5D11 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = Armchair; - targetProxy = E6C9055D19C6433500F41311 /* PBXContainerItemProxy */; + targetProxy = E6D06B5919CB412500DE5D11 /* PBXContainerItemProxy */; + }; + E6D06B5E19CB413600DE5D11 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Armchair; + targetProxy = E6D06B5D19CB413600DE5D11 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */