Skip to content

Commit 36005c2

Browse files
committed
#31, #102 Fixed onResume calling twice
1 parent 83870fd commit 36005c2

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

flutter_apns/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
### 1.6.1
2+
* (#102, #31) resolved invoking onResume twice
3+
14
### 1.6.0
25
* (#97) updated dependencies
36
* enhanced example app
7+
48
### 1.5.4
59
* explicitly mentioned supported platforms in pubspec.yaml
10+
611
### 1.5.3
712
* update firebase dependencies
813
* Add readme: how to run example app in iOS
14+
915
### 1.5.1
1016
* (#58) fix unable to build android (update firebase dependencies)
17+
1118
### 1.5.0-dev.1
1219
* (#51) Update firebase push connector to support the firebase_messaging 9.0.0. API
1320
* (#43) Fix onLaunch not working with closed app

flutter_apns/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_apns
22
description: APNS push notification plugin. Uses firebase_messaging on Android, but replaces it on iOS with custom implementation.
3-
version: 1.6.0
3+
version: 1.6.1
44
homepage: https://github.com/mwaylabs/flutter-apns
55

66
plugin:
@@ -19,7 +19,7 @@ dependencies:
1919
sdk: flutter
2020
firebase_core: ^2.1.1
2121
firebase_messaging: ^14.0.3
22-
flutter_apns_only: ^1.5.2
22+
flutter_apns_only: ^1.6.1
2323

2424
dev_dependencies:
2525
flutter_test:

flutter_apns_only/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.6.1
2+
* removed didReceiveRemoteNotification callback since it is deprecated
3+
* resolved invoking onResume twice
4+
15
## 1.6.0
26
* upgraded together with flutter_apns main package
37
* unify version number

flutter_apns_only/ios/Classes/FlutterApnsPlugin.swift

+6-16
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,6 @@ func getFlutterError(_ error: Error) -> FlutterError {
183183
channel.invokeMethod("onToken", arguments: deviceToken.hexString)
184184
}
185185

186-
187-
public func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) -> Bool {
188-
let userInfo = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
189-
190-
if resumingFromBackground {
191-
onResume(userInfo: userInfo)
192-
} else {
193-
channel.invokeMethod("onMessage", arguments: userInfo)
194-
}
195-
196-
completionHandler(.noData)
197-
return true
198-
}
199-
200186
public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
201187
let userInfo = notification.request.content.userInfo
202188

@@ -212,8 +198,8 @@ func getFlutterError(_ error: Error) -> FlutterError {
212198
completionHandler([.alert, .sound])
213199
} else {
214200
completionHandler([])
215-
let userInfo = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
216-
self.channel.invokeMethod("onMessage", arguments: userInfo)
201+
let dict = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
202+
self.onMessage(userInfo: dict)
217203
}
218204
}
219205
}
@@ -239,6 +225,10 @@ func getFlutterError(_ error: Error) -> FlutterError {
239225
func onResume(userInfo: [AnyHashable: Any]) {
240226
channel.invokeMethod("onResume", arguments: userInfo)
241227
}
228+
229+
func onMessage(userInfo: [AnyHashable: Any]) {
230+
channel.invokeMethod("onMessage", arguments: userInfo)
231+
}
242232
}
243233

244234
extension UNNotificationCategoryOptions {

flutter_apns_only/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_apns_only
22
description: APNS push notification plugin. Works only on iOS. See flutter_apns for apns & firebase combo
3-
version: 1.6.0
3+
version: 1.6.1
44
homepage: https://github.com/mwaylabs/flutter-apns
55

66
environment:

0 commit comments

Comments
 (0)