iOS Restore Auto Renewal Subscriptions - ios

It's ok call restoreCompletedTransactions method once the user opens the app?
Or should Should I enqueue the method invocation in a background thread? Is it consider a blocking thread?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
registerForPushNotifications()
handleRemoteNotifications(launchOptions: launchOptions)
LoveSubscriptions.store.requestProducts(nil)
LoveSubscriptions.store.restorePurchases()
return true
}

Related

Background fetch never fires without Xcode

Background fetch works when i use Xcode's background fetch simulation. But when device is not connected to Xcode, background fetch not calls for about many hours of testing.
I enabled capabilities, my app is not terminated. Any suggestions?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
return true
}
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
let request = WeatherRequest(url: weatherUrl(for: "city"))
request.perform{result in
// show data in view controller
completionHandler(.newData)
}
}

Firebase Crashlytics integration not detecting or reporting crashes

I have integrated Crashlytics , here are the changes i have done.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Fabric.with([Crashlytics.self()])
Crashlytics.sharedInstance().debugMode = true
Have you added a key like.
"${PODS_ROOT}/Fabric/run" ed9c83ee83d41dc717a07531450c480895e41264 b6cc34ec354a4f96ab160958b4s2a01cc321be62acaa6116983376a5113c9s36

Why beforeInAppMessageDisplayed is never called?

I want to use Braze to send in-app message notification and show customized UI to replace the UI created by Braze. But beforeInAppMessageDisplayed is never called. Below is how I done.
I added
Appboy.start(withApiKey: apiKey, in: application, withLaunchOptions: launchOptions, withAppboyOptions: [ ABKInAppMessageControllerDelegateKey: self ]) in func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
and also added
func beforeInAppMessageDisplayed(inAppMessage: ABKInAppMessage!) -> ABKInAppMessageDisplayChoice
in AppDelegate class.
I resolved this issue by putting func beforeInAppMessageDisplayed(inAppMessage: ABKInAppMessage!) -> ABKInAppMessageDisplayChoice in ABKInAppMessageControllerDelegate.

Swift 3: Getting data asynchronously before iPhone app launched

In my app I have to get some data from webmethod before app launched, so I have to call a webmethod in this function:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {}
How can I block the function until the webmethod return its result?

Use of undeclared type 'UIApplicationLaunchOptionsKey'

Recently converted a project to Swift 2.2 and running into issues that didn't exist prior. I've tried searching for a workaround but haven't found any similar posts.
Use of undeclared type 'UIApplicationLaunchOptionsKey'.
I can't tell what's wrong with this code in the AppDelegate.swift:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
//UIToolbar.appearance().tintColor = UIColor.clearColor()
return true
}
Try changing the method signature to
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
The signature is modified to func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool in swift 3
In Swift 3 the method is changed to:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

Resources