Skip to content

Commit 46ce295

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

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
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

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.6.1
2+
* resolved invoking onResume twice
3+
14
## 1.6.0
25
* upgraded together with flutter_apns main package
36
* unify version number

flutter_apns_only/ios/Classes/FlutterApnsPlugin.swift

+14-20
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,17 @@ func getFlutterError(_ error: Error) -> FlutterError {
182182
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
183183
channel.invokeMethod("onToken", arguments: deviceToken.hexString)
184184
}
185-
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
185+
186+
public func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) -> Bool {
187+
let userInfo = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
188+
189+
if resumingFromBackground {
190+
} else {
191+
channel.invokeMethod("onMessage", arguments: userInfo)
192+
}
193+
194+
completionHandler(.noData)
195+
return true
198196
}
199197

200198
public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
@@ -212,8 +210,8 @@ func getFlutterError(_ error: Error) -> FlutterError {
212210
completionHandler([.alert, .sound])
213211
} else {
214212
completionHandler([])
215-
let userInfo = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
216-
self.channel.invokeMethod("onMessage", arguments: userInfo)
213+
let dict = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
214+
self.channel.invokeMethod("onMessage", arguments: dict)
217215
}
218216
}
219217
}
@@ -232,13 +230,9 @@ func getFlutterError(_ error: Error) -> FlutterError {
232230
return
233231
}
234232

235-
onResume(userInfo: dict)
233+
channel.invokeMethod("onResume", arguments: dict)
236234
completionHandler()
237235
}
238-
239-
func onResume(userInfo: [AnyHashable: Any]) {
240-
channel.invokeMethod("onResume", arguments: userInfo)
241-
}
242236
}
243237

244238
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)