diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bba8df..e898bca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 7.2.5 + +* Fixed a bug due to which the request for permission to send push notifications did not appear on IOS. + # 7.2.4 * Fixed a bug that did not allow you to remove a subscription to a RT event in Android. diff --git a/README.md b/README.md index 72bcfd1..b49ca77 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Follow the steps below to get started with Backendless Flutter SDK: To use this plugin in your Flutter project, add `backendless_sdk` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/): ```dart dependencies: - backendless_sdk: ^7.2.4 + backendless_sdk: ^7.2.5 ``` #### STEP 2. Import the Backendless SDK: Add the following import to your Dart code diff --git a/ios/Classes/CallHandlers/MessagingCallHandler.swift b/ios/Classes/CallHandlers/MessagingCallHandler.swift index 55a2a92..aef6a32 100644 --- a/ios/Classes/CallHandlers/MessagingCallHandler.swift +++ b/ios/Classes/CallHandlers/MessagingCallHandler.swift @@ -10,7 +10,7 @@ import Foundation import Flutter import Backendless -class MessagingCallHandler: FlutterCallHandlerProtocol { +class MessagingCallHandler: NSObject, FlutterCallHandlerProtocol, UNUserNotificationCenterDelegate { // MARK: - // MARK: - Constants @@ -317,11 +317,31 @@ class MessagingCallHandler: FlutterCallHandlerProtocol { registerDeviceArgs[Args.channels] = arguments[Args.channels] registerDeviceArgs[Args.expiration] = arguments[Args.expiration] - DispatchQueue.main.async { [weak self] in + if #available(iOS 10.0, *) { + let center = UNUserNotificationCenter.current() + center.delegate = self + center.requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in + if let error = error { + print(":red_circle: APNS error: \(error.localizedDescription)") + } + else { + DispatchQueue.main.async { + UIApplication.shared.registerForRemoteNotifications() + self.didAskRegistration = true + self.registerDeviceFinished = result + } + } + } + } else { + let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) + UIApplication.shared.registerUserNotificationSettings(settings) UIApplication.shared.registerForRemoteNotifications() - self?.didAskRegistration = true - self?.registerDeviceFinished = result } + // DispatchQueue.main.async { [weak self] in + // + // UIApplication.shared.registerForRemoteNotifications() + // self?.didAskRegistration = true + // self?.registerDeviceFinished = result } func didRegisterForRemotePushNotifications(withToken deviceToken: Data) { diff --git a/pubspec.yaml b/pubspec.yaml index f147843..b8e0f9b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: backendless_sdk description: Flutter plugin for Backendless SDK. It provides access to the Backendless services that enable the server-side functionality for developing and running mobile and desktop apps. -version: 7.2.4 +version: 7.2.5 homepage: https://backendless.com environment: