archive-com.com » COM » T » TECHOTOPIA.COM

Total: 1018

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Making Store Purchases with the iOS 7 SKStoreProductViewController Class - Techotopia
    www apple com itunes affiliates resources documentation itunes store web service search api html When the user has finished in the store view a delegate method is called to notify the application at which point the store view controller can be dismissed The remainder of this chapter will work through the creation of a simple example application to demonstrate the use and implementation of the SKStoreProductViewController class Creating the Example Project The example application created in this chapter will consist of a single button which when touched will display the store kit view controller primed with a specified product Launch Xcode and create a new project by selecting the options to create a new iOS application based on the Single View Application template Enter StoreKitDemo as the product name and class prefix and set the device to iPhone Creating the User Interface Within the project navigator panel select the Main storyboard file and drag and drop a Button from the Object Library to the center of the view Double click on the button text and change it to Buy Now so that the layout matches Figure 83 1 Display the Assistant Editor and make sure it is showing the code for the StoreKitDemoViewController h file Select the button in the view and then Ctrl click on it and drag the resulting line to a location just beneath the interface line in the Assistant Editor panel Release the line and in the resulting panel change the connection type to Action and name the method showStoreView Click on the Connect button and close the Assistant Editor panel Figure 83 1 eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Displaying the Store Kit Product View Controller When the user touches the Buy Now button the SKStoreProductViewController instance needs to be created configured and displayed Before writing this code however it will be necessary to declare the StoreKitDemoViewController class as implementing the SKStoreProductViewControllerDelegate protocol The StoreKit StoreKit h file also needs to be imported Both of these tasks need to be performed in the StoreKitDemoViewController h file which should be modified to read as follows import UIKit UIKit h import StoreKit StoreKit h interface StoreKitDemoViewController UIViewController SKStoreProductViewControllerDelegate IBAction showStoreView id sender end Within the StoreKitDemoViewController m file locate the stub showStoreView method and implement the code as outlined in the following listing IBAction showStoreView id sender SKStoreProductViewController storeViewController SKStoreProductViewController alloc init storeViewController delegate self NSDictionary parameters SKStoreProductParameterITunesItemIdentifier NSNumber numberWithInteger 676059878 storeViewController loadProductWithParameters parameters completionBlock BOOL result NSError error if result self presentViewController storeViewController animated YES completion nil The code begins by creating and initializing a new SKStoreProductViewController instance SKStoreProductViewController storeViewController SKStoreProductViewController alloc init Next the view controller class assigns itself as the delegate for the storeViewController instance storeViewController delegate self An NSDictionary instance is then created and initialized with a key of

    Original URL path: http://www.techotopia.com/index.php/Making_Store_Purchases_with_the_iOS_7_SKStoreProductViewController_Class (2016-02-13)
    Open archived version from archive


  • Building In-App Purchasing into iOS 7 Applications - Techotopia
    product in products Handle invalid product IDs if required Each SKProduct object will contain product information name description and price and a Boolean property indicating whether the product has associated with it downloadable content hosted on the App Store There is no SKStoreProductViewController equivalent for in app purchasing It is the responsibility of the application therefore to create and display a view where the user can review the product details which should be extracted from the SKProduct object rather than hard coded into the application code and initiate or cancel the purchase Accessing the Payment Queue In order to process the purchase in the event that the user decides to buy the product it will be necessary for the application to place requests on the application s payment queue The SKPaymentQueue instance is not an object that is created by the application but rather an existing object on which the application makes method calls One such method call must be made in order to assign a transaction observer object to the queue void viewDidLoad super viewDidLoad SKPaymentQueue defaultQueue addTransactionObserver self Since the payment queue continues to process requests independently of the application and even in the event that the application exits it is recommended that access to the payment queue and transaction observer object assignment takes place when the application is first launched This will ensure that the application will be notified immediately of any payment transactions that were completed after the application last exited The Transaction Observer Object The transaction observer object assigned to the payment queue can be an instance of any class within the application that implements the SKPaymentTransactionObserver protocol Compliance with the protocol involves at a minimum implementing the updatedTransactions method If the application is required to download App Store hosted content the updatedDownloads method also needs to be implemented In the event that downloads are to be performed the updatedDownloads method will be called at regular intervals providing status updates on the download progress eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Initiating the Purchase In order to process the purchase the application creates a payment request in the form of an SKPayment object containing the matching SKProduct object for the item this is usually just a case of using the object passed through to the productsRequest method The payment request is then placed into the SKPaymentQueue which is then responsible for communicating with the App Store to process the purchase SKPayment payment SKPayment paymentWithProduct product SKPaymentQueue defaultQueue addPayment payment The Transaction Process The payment queue will call the updatedTransactions method on the observer object when the purchase is complete passing through as an argument an array of SKPaymentTransaction objects one for each item purchased The method will need to check the transactionState property of each transaction object to verify the success or

    Original URL path: http://www.techotopia.com/index.php/Building_In-App_Purchasing_into_iOS_7_Applications (2016-02-13)
    Open archived version from archive

  • Preparing an iOS 7 Application for In-App Purchases - Techotopia
    iOS provisioning portal and enable In App Purchasing for that ID load the project into Xcode and select the application name target from the top of the project navigator panel From the resulting project settings panel select the Capabilities tab and locate and switch on In App Purchase support as outlined in Figure 85 1 selecting a Development Team to use for the provisioning profile if prompted to do so Figure 85 1 eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Configuring the Application in iTunes Connect Enrollment in the Apple Developer program automatically results in the creation of an iTunes Connect account using the same login credentials iTunes Connect is a web portal where developers enter tax and payment information input details about applications and track the status of those applications in terms of sales and revenues Access iTunes Connect by navigating to http itunesconnect apple com in a web browser and entering your Apple Developer program login and password details First time users should click on the Contracts Taxes and Banking link and work through the various tasks to accept Apple s terms and conditions and to input appropriate tax and banking information for the receipt of sales revenue Failure to complete these steps in advance may prevent in app purchases from working In order to test in app purchases using the sandbox feature it is first necessary to create a test user account These are the account details that will be entered on the device when testing in app purchases Within iTunes Connect click on the Manage Users link On the Select User Type screen select the Test User category then Add New User When prompted enter the credentials for the test user taking care not to try to use an email address already associated with an active iTunes account Once the administrative tasks are complete select the Manage Your Applications option followed by Add New App Provide an App Name this must be a name that has not been used by another developer so may involve some trial and error and a SKU Number which can be any sequence of characters involving letters numbers hyphens underscores and periods From the Bundle ID menu select the InAppDemo Xcode iOS App ID bundle created previously On the subsequent screens configure information relating to pricing availability content and images before saving the new application configuration Creating an In App Purchase Item With the application configured the next step is to add an in app purchase item to it Within iTunes Connect select Manage Your Apps A new screen will appear including any apps previously configured including the new InAppDemo app Click on the application in the list to navigate to the App Information screen as illustrated in Figure 85 2 Figure 85 2 To configure an in

    Original URL path: http://www.techotopia.com/index.php/Preparing_an_iOS_7_Application_for_In-App_Purchases (2016-02-13)
    Open archived version from archive

  • An iOS 7 In-App Purchase Tutorial - Techotopia
    InAppDemoViewController h file and modify it to import StoreKit StoreKit h and PurchaseViewController h Also declare a method named enableLevel2 and add a property to store a reference to an instance of the PurchaseViewController class import UIKit UIKit h import StoreKit StoreKit h import PurchaseViewController h interface InAppDemoViewController UIViewController IBAction purchaseItem id sender property strong nonatomic IBOutlet UIButton level2Button property strong nonatomic PurchaseViewController purchaseController void enableLevel2 end Open the InAppDemoViewController m file and modify the viewDidLoad method to create an instance of the PurchaseViewController class and to designate it as the transaction observer for the payment queue void viewDidLoad super viewDidLoad purchaseController PurchaseViewController alloc init SKPaymentQueue defaultQueue addTransactionObserver purchaseController When the Buy Level 2 Access button is selected the purchaseItem method is configured to be called Locate the stub of this method and modify it as follows where YOUR PRODUCT ID GOES HERE is replaced by the product ID you created in iTunes Connect in the previous chapter IBAction purchaseItem id sender purchaseController productID YOUR PRODUCT ID GOES HERE self navigationController pushViewController purchaseController animated YES purchaseController getProductInfo self Note that if the product ID specified does not match that defined for the in app purchase item created using iTunes Connect in the previous chapter purchase attempts will fail Finally implement the enableLevel2 method which will be called to enable the Level 2 access button once the purchase is complete void enableLevel2 level2Button enabled YES The InAppDemoViewController class is now complete Completing the PurchaseViewController Class The first steps in completing the PurchaseViewController class are to locally import the InAppDemoViewController h file and use the class extension mechanism in the implementation file to declare a property that is private to the PurchaseViewController m file in which to store a reference to the In App Demo View Controller object Select PurchaseViewController m in the project navigator therefore and modify it as follows import PurchaseViewController h import InAppDemoViewController h interface PurchaseViewController property strong nonatomic InAppDemoViewController homeViewController end implementation PurchaseViewController end Until the product information has been obtained the buy button should be disabled so modify the viewDidLoad method accordingly void viewDidLoad super viewDidLoad buyButton enabled NO eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters When the user decides to purchase Level 2 access the getProductInfo method of the PurchaseViewController instance will be called by the InAppDemoViewController instance Passed as an argument to this method will be a reference to the InAppDemoViewController instance which needs to be saved in the previously declared homeViewController property It will then be the job of the getProductInfo method to contact the App Store and get product information for the specified ID The code for this belongs in PurchaseViewController m and reads as follows void getProductInfo InAppDemoViewController viewController homeViewController viewController if SKPaymentQueue canMakePayments SKProductsRequest request SKProductsRequest alloc initWithProductIdentifiers NSSet setWithObject self productID request delegate self request start else

    Original URL path: http://www.techotopia.com/index.php/An_iOS_7_In-App_Purchase_Tutorial (2016-02-13)
    Open archived version from archive

  • Configuring and Creating App Store Hosted Content for iOS 7 In-App Purchases - Techotopia
    for Upload Figure 87 1 The Anatomy of an In App Purchase Hosted Content Package An in app purchase hosted content package consists of a structured folder the root level of which must contain a ContentInfo plist file which in turn contains two keys ContentVersion The version number of the content IAPProductIdentifier The product identifier of the product with which the content is associated The folder must also contain a sub folder named Contents in which resides the content files associated with the in app purchase App Store hosted content packages are limited to 2GB in size and must not contain executable code or content that violates any of Apple s guidelines eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Creating an In App Purchase Hosted Content Package The easiest way to create a hosted content package is to use Xcode To do so launch Xcode and create a new project When prompted to select a template for the new project select the Other entry listed under iOS in the left hand panel of the template screen and in the main panel select In App Purchase Content as demonstrated in Figure 87 2 Figure 87 2 Click Next and on the subsequent screen enter a name for the content package which matches the product ID of the purchase item as declared in iTunes Connect Click Next and choose a location for the project before clicking on the Create button Within the main Xcode screen unfold the Supporting Files section of the project navigator panel and select the ContentInfo plist file Review the contents of the file and note that the version is set to 1 0 by default Since this is the first version of the content this can be left unchanged If the content is modified at any point in the future this version number should be incremented accordingly Using a Finder window locate the content files that are to be hosted on the App Store and drag and drop them onto the Supporting Files header in the Xcode project navigator panel and click Finish on the resulting panel Archiving the Hosted Content Package With the content configured the next step is to create the hosted content package file This is achieved by selecting the Xcode Product Archive menu option Once the package has been created display the Organizer window and select the Archives tab as shown in Figure 87 3 Figure 87 3 Validating the Hosted Content Package Before the package is uploaded to Apple s servers it should first be validated to ensure it does not contain ineligible content To perform the verification click on the Validate button in the Organizer window and enter your Apple developer program credentials to verify that the content meets Apple s format guidelines Xcode will then ask that the

    Original URL path: http://www.techotopia.com/index.php/Configuring_and_Creating_App_Store_Hosted_Content_for_iOS_7_In-App_Purchases (2016-02-13)
    Open archived version from archive

  • Preparing and Submitting an iOS 7 Application to the App Store - Techotopia
    device family after asset catalogs have been turned off Figure 88 3 For each image the required dimensions are listed next to each image category One way to add images is to click on the corresponding folder icon to the right of each line and in the resulting panel click on the Add Other button and locate and select the image that matches the dimensions for that particular asset For additional information on the role of each image simply move the mouse pointer over the folder icon and wait for the information panel to appear Once an image has been uploaded it can be viewed by clicking on the eye icon that will appear next to the folder Rather than continue to add images using this approach however it is more efficient to migrate the images to an asset catalog This is achieved by clicking on the Use Asset Catalog buttons Once the images have been migrated to an asset catalog it may be viewed by selecting the Images xcassets file in the project navigator panel as illustrated in Figure 88 4 Assuming that both the lauch images and app icons have been migrated to the asset catalog entries will be listed for both named AppIcon and LaunchImage by default Figure 88 4 To add additional images simply drag and drop the missing image files from a Finder window onto the corresponding placeholders in the asset catalog eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Targeting 32 bit and 64 bit Architectures With the introduction the iPhone 5s apps can be built for both 32 bit and 64 bit processor architectures In the event that you have written 64 bit compatible code an application archive that targets both 32 bit and 64 bit architectures can be configured by selecting the Build Settings tab in the project settings panel and changing the Architectures setting for the application to Standard architectures including 64 bit as illustrated in Figure 88 5 Figure 88 5 If migrating an existing 32 bit application to 64 bit an outline of the areas where code changes may be necessary is provided by Apple at https developer apple com library etc redirect itms CocoaTouch64BitGuide Archiving the Application for Distribution The application must now be rebuilt using the previously installed distribution profile To generate the archive select the Xcode Product Archive menu option Note that if the Archive menu is disabled this is most likely because the a simulator option is currently selected as the run target in the Xcode toolbar Changing this menu either to a connected device or the generic iOS Device target option should enable the Archive option in Product menu Xcode will proceed to archive the application ready for submission Once the process is complete the archive will be displayed in the Organizer

    Original URL path: http://www.techotopia.com/index.php/Preparing_and_Submitting_an_iOS_7_Application_to_the_App_Store (2016-02-13)
    Open archived version from archive

  • Promoting your iOS Apps using iAd Workbench - Techotopia
    have downloaded similar applications in the past Once the campaign details have been defined banner ad artwork may be uploaded or a banner ad created within a few minutes using one of the Apple provided templates Creating a New iAds Campaign The first step in creating a new iAds campaign for an iOS app is to log into iAd Workbench at http iadworkbench apple com When prompted enter your existing Apple ID and password to log into the workbench environment at which point the Dashboard page shown in Figure 89 1 will appear listing any currently configured campaigns Figure 89 1 Each campaign is assigned to a specific app After logging in for the first time there will be no current campaigns listed Begin the process of creating a new campaign therefore by clicking on the Create Campaign button located in the top right hand corner of the Dashboard The first step in creating a campaign is to select the app which is to be promoted Using the Apple ID information entered at login the workbench will extract a list of applications currently configured in iTunes Connect for that ID In the event that no apps are listed make sure that the Apple ID used to log into the iAds Workbench matches that used for your iTunes Connect access Assuming that the workbench has located the apps in iTunes Connect a page similar to that illustrated in Figure 89 2 will appear Figure 89 2 Select the app for which the campaign is being created alternatively click on the Add an App entry to specify an app using either an App ID or App Store URL and enter a name for the campaign in the Name Your Campaign field before clicking on the Next button eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Campaign Targeting Options The next screen Figure 89 3 provides a range of options relating to the target for the campaign the duration for which the ad is to run and the budget information Figure 89 3 To leave the campaign targeting at the discretion of the iAds system leave the Targeting Option set to Auto To specify your own demographic settings change the mode to Manual and work through the different categories listed to define how and where the ad campaign will be targeted Enter the start and end dates for the campaign into the flight date fields before entering the campaign budget information The information to be entered here is as follows Budget The total amount budgeted to be spent over the entire life of the campaign Daily Spend Goal An optional value declaring the average total amount to be spent on the campaign per day The minimum is 10 CPC Bid The maximum amount you are willing to bid for each click

    Original URL path: http://www.techotopia.com/index.php/Promoting_your_iOS_Apps_using_iAd_Workbench (2016-02-13)
    Open archived version from archive

  • IOS 7 App Development Essentials - Techotopia
    Implementing the Notification Method Implementing the saveData Method iOS 7 Data Persistence using Archiving An Overview of Archiving The Archiving Example Application Designing the User Interface Checking for the Existence of the Archive File on Startup Archiving Object Data in the Action Method Testing the Application iOS 7 Database Implementation using SQLite What is SQLite Structured Query Language SQL Trying SQLite on MacOS X Preparing an iOS Application Project for SQLite Integration Key SQLite Functions Declaring a SQLite Database Opening or Creating a Database Preparing and Executing a SQL Statement Creating a Database Table Extracting Data from a Database Table Closing a SQLite Database An Example SQLite based iOS 7 Application About the Example SQLite Application Creating and Preparing the SQLite Application Project Importing sqlite3 h and declaring the Database Reference Designing the User Interface Creating the Database and Table Implementing the Code to Save Data to the SQLite Database Implementing Code to Extract Data from the SQLite Database Building and Running the Application Working with iOS 7 Databases using Core Data The Core Data Stack Managed Objects Managed Object Context Managed Object Model Persistent Store Coordinator Persistent Object Store Defining an Entity Description Obtaining the Managed Object Context Getting an Entity Description Creating a Managed Object Getting and Setting the Attributes of a Managed Object Fetching Managed Objects Retrieving Managed Objects based on Criteria An iOS 7 Core Data Tutorial The Core Data Example Application Creating a Core Data based Application Creating the Entity Description Adding a Storyboard to the Project Adding a View Controller Designing the User Interface Saving Data to the Persistent Store using Core Data Retrieving Data from the Persistent Store using Core Data Building and Running the Example Application An Overview of iOS 7 Multitouch Taps and Gestures The Responder Chain Forwarding an Event to the Next Responder Gestures Taps Touches Touch Notification Methods touchesBegan method touchesMoved method touchesEnded method touchesCancelled method An Example iOS 7 Touch Multitouch and Tap Application The Example iOS 7 Tap and Touch Application Creating the Example iOS Touch Project Designing the User Interface Enabling Multitouch on the View Implementing the touchesBegan Method Implementing the touchesMoved Method Implementing the touchesEnded Method Getting the Coordinates of a Touch Building and Running the Touch Example Application Detecting iOS 7 Touch Screen Gesture Motions The Example iOS 7 Gesture Application Creating the Example Project Designing the Application User Interface Implementing the touchesBegan Method Implementing the touchesMoved Method Implementing the touchesEnded Method Building and Running the Gesture Example Identifying Gestures using iOS 7 Gesture Recognizers The UIGestureRecognizer Class Recognizer Action Messages Discrete and Continuous Gestures Obtaining Data from a Gesture Recognizing Tap Gestures Recognizing Pinch Gestures Detecting Rotation Gestures Recognizing Pan and Dragging Gestures Recognizing Swipe Gestures Recognizing Long Touch Touch and Hold Gestures An iOS 7 Gesture Recognition Tutorial Creating the Gesture Recognition Project Designing the User Interface Implementing the Action Methods Testing the Gesture Recognition Application An Overview of iOS 7 Collection View and Flow Layout An Overview of Collection Views The UICollectionView Class The UICollectionViewCell Class The UICollectionReusableView Class The UICollectionViewFlowLayout Class The UICollectionViewLayoutAttributes Class The UICollectionViewDataSource Protocol The UICollectionViewDelegate Protocol The UICollectionViewDelegateFlowLayout Protocol Cell and View Reuse An iOS 7 Storyboard based Collection View Tutorial Creating the Collection View Example Project Removing the Template View Controller Adding a Collection View Controller to the Storyboard Adding the Collection View Cell Class to the Project Designing the Cell Prototype Implementing the Data Model Implementing the Data Source Testing the Application Setting Sizes for Cell Items Changing Scroll Direction Implementing a Supplementary View Implementing the Supplementary View Protocol Methods Deleting Collection View Items Subclassing and Extending the iOS 7 Collection View Flow Layout About the Example Layout Class Subclassing the UICollectionViewFlowLayout Class Extending the New Layout Class Implementing the layoutAttributesForItemAtIndexPath Method Implementing the layoutAttributesForElementsInRect Method Implementing the modifyLayoutAttributes Method Adding the New Layout and Pinch Gesture Recognizer Implementing the Pinch Recognizer Avoiding Image Clipping Testing the Application Drawing iOS 7 2D Graphics with Core Graphics Introducing Core Graphics and Quartz 2D The drawRect Method Points Coordinates and Pixels The Graphics Context Working with Colors in Quartz 2D An iOS 7 Graphics Tutorial using Core Graphics and Core Image The iOS Drawing Example Application Creating the New Project Creating the UIView Subclass Locating the drawRect Method in the UIView Subclass Drawing a Line Drawing Paths Drawing a Rectangle Drawing an Ellipse or Circle Filling a Path with a Color Drawing an Arc Drawing a Cubic Bézier Curve Drawing a Quadratic Bézier Curve Dashed Line Drawing Drawing Shadows Drawing Gradients Drawing an Image into a Graphics Context Image Filtering with the Core Image Framework Basic iOS 7 Animation using Core Animation UIView Core Animation Blocks Understanding Animation Curves Receiving Notification of Animation Completion Performing Affine Transformations Combining Transformations Creating the Animation Example Application Implementing the Interface File Drawing in the UIView Detecting Screen Touches and Performing the Animation Building and Running the Animation Application iOS 7 UIKit Dynamics An Overview Understanding UIKit Dynamics The UIKit Dynamics Architecture Dynamic Items Dynamic Behaviors The Reference View The Dynamic Animator Implementing UIKit Dynamics in an iOS 7 Application Dynamic Animator Initialization Configuring Gravity Behavior Configuring Collision Behavior Configuring Attachment Behavior Configuring Snap Behavior Configuring Push Behavior The UIDynamicItemBehavior Class Combining Behaviors to Create a Custom Behavior An iOS 7 UIKit Dynamics Tutorial Creating the UIKit Dynamics Example Project Adding the Dynamic Items Creating the Dynamic Animator Instance Adding Gravity to the Views Implementing Collision Behavior Attaching a View to an Anchor Point Implementing a Spring Attachment Between two Views An Introduction to iOS 7 Sprite Kit Programming What is Sprite Kit The Key Components of a Sprite Kit Game Sprite Kit View Scenes Nodes Physics Bodies Physics World Actions Transitions Texture Atlas An Example Sprite Kit Game Hierarchy The Sprite Kit Game Rendering Loop An iOS 7 Sprite Kit Game Tutorial About the Sprite Kit Demo Game Creating the SpriteKitDemo Project Reviewing the SpriteKit Game Template Project Creating the Game Scene Classes Implementing the Welcome Scene Transitioning to

    Original URL path: http://www.techotopia.com/index.php?title=IOS_7_App_Development_Essentials&oldid=21406 (2016-02-13)
    Open archived version from archive



  •