I am making an attempt to configure push notifications with back4app backend in my iOS app utilizing this information: https://www.back4app.com/docs/ios/push-notifications/ios-send-push-notification-from-server
import UIKit
import ParseSwift
import StoreKit
import UserNotifications
@primary
class AppDelegate: UIResponder, UIApplicationDelegate {
let server: ServerFeaturesProtocols = ParseServerService()
func utility(_ utility: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override level for personalisation after utility launch.
ParseSwift.initialize(applicationId: "applicationID", clientKey: "clientKey", serverURL: URL(string: "https://serverURl")!)
UNUserNotificationCenter.present().requestAuthorization(choices: [.alert, .badge, .sound, .carPlay]) { granted, error in
guard granted else { return }
self.getNotificationSettings()
}
print("sessionToken (PSUser.present?.sessionToken)")
if let appStoreReceiptURL = Bundle.primary.appStoreReceiptURL,
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
if let receiptData = strive? Information(contentsOf: appStoreReceiptURL, choices: .alwaysMapped) {
let receiptString = receiptData.base64EncodedString(choices: [])
}
}
SKPaymentQueue.default().add(SubscriptionManager.shared)
SubscriptionManager.shared.fetchAvailableProducts()
return true
}
func getNotificationSettings() {
UNUserNotificationCenter.present().getNotificationSettings { (settings) in
print("Notification settings: (settings)")
guard settings.authorizationStatus == .approved else { return }
UIApplication.shared.registerForRemoteNotifications()
}
}
func utility(_ utility: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, choices: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(title: "Default Configuration", sessionRole: connectingSceneSession.position)
}
func utility(_ utility: UIApplication, didDiscardSceneSessions sceneSessions: Set) {}
func utility(_ utility: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Information) {
createInstallationOnParse(deviceTokenData: deviceToken)
}
func utility(_ utility: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Did not register for distant notifications: (error.localizedDescription)")
}
func applicationWillTerminate(_ utility: UIApplication) {
SKPaymentQueue.default().take away(SubscriptionManager.shared)
}
func createInstallationOnParse(deviceTokenData:Information){
if let set up = PFInstallation.present {
set up.setDeviceTokenFrom(deviceTokenData)
set up.saveInBackground {
(success: Bool, error: Error?) in
if (success) {
print("You've efficiently saved your push set up to Back4App!")
} else {
if let myError = error {
print("Error saving parse set up (myError.localizedDescription)")
} else {
print("Uknown error")
}
}
}
}
}
}
I obtain an error: Can not discover ‘PFInstallation’ in scope though I’ve all imports
I attempted exchange PFInstallation with ParseInstallation however it did not work