Closed defiantgoat closed 2 months ago
cc @luketgriffith
Same issue here, it would be nice to be able to call directly instead of calling into an ObjC class
import UIKit
import Flutter
+import TSBackgroundFetch
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
.
.
.
+ TSBackgroundFetch.sharedInstance().didFinishLaunching();
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Updated Setup Instructions
I don't think it's a good idea to use Swift with the AppDelegate
, until RN provides a built-in way to generate one. And when RN changes the source of their AppDelegate.m
in the future (and they will), then you're screwed and you have to manually translate the changes to Swift. Stackoverflow is full of many different versions of AppDelegeate.swift
through various versions of RN dating back years.
:open_file_folder: AppDelegate.swift
:
import Foundation
import UIKit
+import TSBackgroundFetch
@UIApplicationMain
class AppDelegate: RCTAppDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
.
.
.
+ // [REQUIRED] Register BackgroundFetch
+ TSBackgroundFetch.sharedInstance().didFinishLaunching();
return self.application(application, didFinishLaunchingWithOptions: launchOptions);
}
}
We have migrated to an AppDelegate.swift model with a bridging header. Would be good to provide a swift example for this part > https://github.com/transistorsoft/react-native-background-fetch/blob/master/docs/INSTALL-AUTO-IOS.md#appdelegatem-new-ios-13