I'm trying to convert a method from the React-native Firebase documentation, from Objective-c code to Swift. But it's not working, can someone lend me a help?
The doc I'm following: https://rnfirebase.io/docs/v4.3.x/notifications/ios
This is the Object C part I want to convert and add to the Swift file:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}
At the moment, this is my code, see the commented part:
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var bridge: RCTBridge!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
RNFirebaseNotifications.configure()
let jsCodeLocation: URL
jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource:nil)
let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "Zepplin", initialProperties: nil, launchOptions: launchOptions)
let rootViewController = UIViewController()
rootViewController.view = rootView
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = rootViewController
self.window?.makeKeyAndVisible()
return true
}
/*func application(_ application: UIApplication, didReceiveLocalNotification notification: [UILocalNotification: Any]?) -> Any {
RNFirebaseNotifications.instance(_, didReceiveLocalNotification, notification)
}*/
}
But of corse, it's not working, because the syntax is wrong... I'm not familiar with Swift. Can someone lend me a hand? I would be glad! Thankss in before-hand!!!
EDIT:
Sorry if my question was not clear enough. For me, the question was, "how to fix the syntax?", I knew that the syntax was wrong. I had nothing to add to my question, the error Xcode was giving me was expected, obvious because I don't know Objective-C, nor Swift, I was trying in my way. Even if I added the error to the question, I'm sure that something else would error too. That's why I asked if someone could convert it for me, it's only a few lines, so I think I was not asking too much.
Thanks @bsod, for mentionating the tool you posted in the comment!! This is exactly the tool I needed. I didn't know that something like this tool existed.
Thanks for everyone that helped me.