Category: iOS

iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company’s mobile devices, including the iPhone and iPod Touch; the term also included the versions running on iPads until the name iPadOS was introduced with version 13 in 2019. It is the world’s second-most widely installed mobile operating system, after Android. It is the basis for three other operating systems made by Apple: iPadOS, tvOS, and watchOS. It is proprietary software, although some parts of it are open source under the Apple Public Source License and other licenses.

  • Essential App Store Checklist: Launch Your App with Confidence

    Essential App Store Checklist: Launch Your App with Confidence

    This blog post “Essential App Store Checklist: Launch Your App with Confidence” provides a comprehensive guide for developers preparing to launch their mobile app on various app stores. It emphasizes the importance of thorough preparation to ensure a smooth launch and successful visibility.

    Key elements:

    • App Design and Functionality: Ensuring that the app is user-friendly and meets the needs of the target audience.
    • App Store Optimization (ASO): Tips on keywords, engaging descriptions, and attractive visuals to enhance discoverability.
      Beta Testing: The significance of testing the app with real users to gather feedback and identify bugs.
    • Compliance and Guidelines: Adhering to the specific submission guidelines set by different app stores to avoid rejections.
    • Marketing Strategy: Planning a promotion strategy that includes social media, content marketing, and engaging press releases.
    • The post concludes with encouragement to follow the checklist diligently, which will help developers launch their apps confidently and improve their chances of success in a competitive marketplace.

    AppStore Listing

    App General Info

    1. App Preview & Screenshots – Screenshots must be in the JPG or PNG format, and in the RGB color space. App previews must be in the M4V, MP4, or MOV format and can’t exceed 500 MB.
    2. Promotional Text – Promotional text lets you inform your App Store visitors of any current app features without requiring an updated submission. This text will appear above your description on the App Store for customers with devices running iOS 11 or later, and macOS 10.13 or later.
    3. Description – A description of your app, detailing features and functionality.
    4. What’s New in This Version – Describe what’s new in this version of your app, such as new features, improvements, and bug fixes.
    5. Keywords – Include one or more keywords that describe your app. Keywords make App Store search results more accurate. Separate keywords with an English comma, Chinese comma, or a mix of both.
    6. Support URL – A URL with support information for your app. This appears on your app’s product page once you release your app on the App Store.
    7. Marketing URL – A URL with marketing information about your app. This URL will be visible on the App Store.
    8. Version – The version of the app you are adding. Numbering should follow software versioning conventions.
    9. Copyright – The name of the person or entity that owns the exclusive rights to your app, preceded by the year the rights were obtained (for example, “2008 Acme Inc.”). Do not provide a URL.
    10. Build – Build of your app version from Xcode
    11. App Icon – Xcode should have it already
    12. App Review Information – If your app has a login window, otherwise you don’t need it.
    13. App Store Version Release – Choose to automatically release this version. Also, you can choose to manually release it or release on a specific date.

    App Information

    1. Name – The name will be reviewed with the next submission of your app.
    2. Subtitle –  A summary of your app that will appear under your app’s name on your App Store product page. This can’t be longer than 30 characters.
    3. Category Primary – The category that best describes this app.
    4. Category Secondary – The category you want after the primary category

    Note: Some of these can be auto populated by Xcode

    App Privacy

    1. Privacy Policy URL – A URL that links to your privacy policy. A privacy policy is required for all apps.
    2. Data collection declaration – Just say the app doesn’t collect any data.

    Pricing and Availability

    1. Prices – Leave it to Free or set your Price.
    2. App Availability – All Countries or you can make it available for only a few countries.

    Xcode

    Set the bundle ID

    When you create your Xcode project from a template, the bundle ID (CFBundleIdentifier), which uniquely identifies your app throughout the system, defaults to the organization ID appended to the app name that you enter in reverse-DNS format—for example, the bundle ID becomes com.example.mycompany.HelloWorld.

    1. Choose the target.
    2. Click the Signing & Capabilities pane.
    3. Expand Signing.
    4. Enter the bundle ID in the Bundle Identifier text field.

    2. Set the supported destinations

    Indicate which devices and platforms your app supports. In the project editor:

    1. Choose the target.
    2. Select the General pane.
    3. Expand the Supported Destinations section.
    4. Click the Add button (+), choose a device and platform. To remove a destination, select it and click the Remove button (-).

    3. Set the app category

    Categories help customers discover your app on the App Store. In App Store Connect, you set the primary and secondary categories that you want your app to appear under in the App Store. For macOS apps, you also set a category for your app in your project.

    Select a category that matches or closely relates to the primary category you set in App Store Connect:

    1. Choose the target.
    2. Select the General pane.
    3. Expand the Identity section.
    4. Choose a category from the App Category pop-up menu.

    For guidance with choosing the most accurate and effective categories, see Choosing a category.

    4. Edit deployment info settings

    For iOS and iPadOS apps, choose the device orientations your app supports.

    5. Add an app icon and App Store icon

    Create icon https://www.candyicons.com/free-tools/app-icon-assets-generator

    Add an icon to represent your app in various locations on a device and on the App Store.

    A project created from a template already contains the image set for app icons. The App Icons and Launch Images section of the General pane displays the name of the asset. Open the asset in the asset catalog to configure the icon ass

    Spread the love
  • Decode Apple Receipt

    Decode Apple Receipt

    Decode Apple Receipt

    Verify with the server-side click here

    /**
     * ***********************************************************************
     *  SMINRANA CONFIDENTIAL
     *   __________________
     *
     * Copyright 2020  SMINRANA
     * All Rights Reserved.
     *
     * NOTICE:  All information contained herein is, and remains
     * the property of SMINRANA and its suppliers,
     * if any.  The intellectual and technical concepts contained
     * herein are proprietary to SMINRANA
     * and its suppliers and may be covered by U.S. and Foreign Patents,
     * patents in process, and are protected by trade secret or copyright law.
     * Dissemination of this information or reproduction of this material
     * is strictly forbidden unless prior written permission is obtained
     * from SMINRANA.
     * www.sminrana.com
     *
     */
    
    import SwiftUI
    import StoreKit
    import Combine
    
    class AppStorageManager: NSObject, ObservableObject, SKProductsRequestDelegate, SKPaymentTransactionObserver {
    
        @AppStorage("username") var username: String = ""
        @AppStorage("password") var password: String = ""
        
        override init() {
            super.init()
            
            SKPaymentQueue.default().add(self)
        }
        
        @Published var products = [SKProduct]()
        
        func getProdcut(indetifiers: [String]) {
            print("Start requesting products ...")
            let request = SKProductsRequest(productIdentifiers: Set(indetifiers))
            request.delegate = self
            request.start()
        }
        
    
        // SKProductsRequestDelegate
    
        func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
            print("Did receive response \(response.products)")
                    
            if !response.products.isEmpty {
                for fetchedProduct in response.products {
                    DispatchQueue.main.async {
                        self.products.append(fetchedProduct)
                    }
                }
            }
            
            for invalidIdentifier in response.invalidProductIdentifiers {
                print("Invalid identifiers found: \(invalidIdentifier)")
            }
        }
        
        func request(_ request: SKRequest, didFailWithError error: Error) {
            print("Request did fail: \(error)")
        }
        
    
        // Transaction
        
        @Published var transactionState: SKPaymentTransactionState?
        
        func purchaseProduct(product: SKProduct) {
            if SKPaymentQueue.canMakePayments() {
                let payment = SKPayment(product: product)
                SKPaymentQueue.default().add(payment)
            } else {
                print("User can't make payment.")
            }
        }
    
        func restorePurchase() {
            SKPaymentQueue.default().restoreCompletedTransactions()
        }
        
        struct PaymentReceiptResponseModel: Codable {
            var status: Int
            var email: String?
            var password: String?
            var message: String?
        }
        
        // SKPaymentTransactionObserver
    
    
        // This gets called when transaction purchased by user
        func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
            for transaction in transactions {
                switch transaction.transactionState {
                case .purchasing:
                    self.transactionState = .purchasing
                case .purchased:
                    print("===============Purchased================")
                    UserDefaults.standard.setValue(true, forKey: transaction.payment.productIdentifier)
    
                    if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
                        FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
    
                        do {
                            let receiptData = try Data(contentsOf: appStoreReceiptURL, options: .alwaysMapped)
                            let receiptString = receiptData.base64EncodedString(options: [])
                            
                           // Send receiptString to server for further verification
                        }
                        catch { print("Couldn't read receipt data with error: " + error.localizedDescription) }
                    }
    
                case .restored:
                    UserDefaults.standard.setValue(true, forKey: transaction.payment.productIdentifier)
    
                    queue.finishTransaction(transaction)
                    print("==================RESTORED State=============")
                    self.transactionState = .restored
                case .failed, .deferred:
                    print("Payment Queue Error: \(String(describing: transaction.error))")
                    queue.finishTransaction(transaction)
                    self.transactionState = .failed
                default:
                    print(">>>> something else")
                    queue.finishTransaction(transaction)
                }
            }
        }
        
        // This gets called when a transaction restored by user
        func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
            print("===============Restored================")
            if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
                FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
    
                do {
                    let receiptData = try Data(contentsOf: appStoreReceiptURL, options: .alwaysMapped)
                    let receiptString = receiptData.base64EncodedString(options: [])
                    
                    // Send receiptString to server for further verification
                }
                catch { print("Couldn't read receipt data with error: " + error.localizedDescription) }
            }
        }
        
      
    }
    
    Spread the love
  • Download PDF in Flutter using Java on Android

    Downloading PDF file in the user download directory on Android is a very common feature, a lot of app uses PDF viewing and downloading feature.

    I hoped that flutter plugins could solve my problem but they didn’t. Fortunately, it was working great on iOS but it was not on android. So I decided to use my old java code in Flutter using Method Channel.

    First I tried two Flutter plugins one for permission and one for creating a directory.

    flutter pub add path_provider
    flutter pub add permission_handler

    Request permission was very easy and it worked on both iOS and Android

    Future<bool> _requestWritePermission() async {
        await Permission.storage.request();
        var r = await Permission.storage.request();
    
        return r.isGranted;
      }

    Since it was working on iOS, I decided to leave that code and separate platform code by importing ‘dart:io’ show Platform. Use this code on your onTap action.

    static const channel = MethodChannel('com.flutterframework/test');
    
    bool hasPermission = await _requestWritePermission();
    
    if (hasPermission) {
      if (Platform.isAndroid) {
        final int downloader = await channel.invokeMethod(
          'download',
          <String, String>{'title': title, 'pdf': pdf},
        );
        print(downloader);
      }
    
      if (Platform.isIOS) {
        var dir = await getApplicationDocumentsDirectory();
        if (dir != null) {
          String saveName = "$title.pdf";
          String savePath = "${dir.path}/$saveName";
          print(savePath);
    
          try {
            await Dio().download(pdf, savePath,
                onReceiveProgress: (received, total) {
              if (total != -1) {
                var percentage = (received / total * 100);
                print(percentage);
                if (percentage >= 100.0) {
                  ScaffoldMessenger.of(context).showSnackBar(
                      snackMessage(
                          'Download completed, please open Files app.'));
                }
              }
            });
            print("File is saved to download folder.");
          } on DioError catch (e) {
            ScaffoldMessenger.of(context).showSnackBar("Download error");
          }
        }
      }
    } else {
      ScaffoldMessenger.of(context).showSnackBar(filePermissionError);
    }
    

    Finally, the Java code, create a Java class in your main directory.

    package your_package;
    
    import android.app.DownloadManager;
    import android.content.Context;
    import android.net.Uri;
    import android.os.Build;
    import android.os.Environment;
    
    public class DownloadHelper {
        public static void downloadPDF(Context context, String title, String pdfUrl) {
            try {
                DownloadManager.Request request = new DownloadManager.Request(Uri.parse(pdfUrl));
                request.setDescription("MyApp");
                request.setTitle(title);
                // in order for this if to run, you must use the android 3.2 to compile your app
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                    request.allowScanningByMediaScanner();
                    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                }
    
                if (Build.VERSION.SDK_INT <= 17) {
                    request.setDestinationInExternalFilesDir(context, "Documents", "MyFolder/" + title + ".pdf");
                } else {
                    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "MyFolder/" + title + ".pdf");
                }
    
                // get download service and enqueue file
                DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
                manager.enqueue(request);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        }
    }
    

    Call that Java code from MainActivity, my MainActivity in Kotlin

    class MainActivity: FlutterActivity() {
        private val CHANNEL = "com.flutterframework/test";
        private lateinit var channel: MethodChannel
    
        override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
            super.configureFlutterEngine(flutterEngine)
            channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
            channel.setMethodCallHandler { call, result ->
                if (call.method == "download") {
                    val pdfTitle = call.argument<String>("title")
                    val pdfUrl = call.argument<String>("pdf")
                    Log.d("TAG", pdfTitle.toString());
                    Log.d("TAG", pdfUrl.toString());
    
                    DownloadHelper.downloadPDF(this, pdfTitle, pdfUrl);
                }
            }
        }
    }

    Download the complete project on GitHub

    Spread the love