Skip to content

Commit

Permalink
#31, #102 Fixed onResume calling twice
Browse files Browse the repository at this point in the history
  • Loading branch information
befirst committed Nov 17, 2022
1 parent 83870fd commit 1bb71c8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
7 changes: 7 additions & 0 deletions flutter_apns/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
### 1.6.1
* (#102, #31) resolved invoking onResume twice

### 1.6.0
* (#97) updated dependencies
* enhanced example app

### 1.5.4
* explicitly mentioned supported platforms in pubspec.yaml

### 1.5.3
* update firebase dependencies
* Add readme: how to run example app in iOS

### 1.5.1
* (#58) fix unable to build android (update firebase dependencies)

### 1.5.0-dev.1
* (#51) Update firebase push connector to support the firebase_messaging 9.0.0. API
* (#43) Fix onLaunch not working with closed app
Expand Down
4 changes: 2 additions & 2 deletions flutter_apns/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_apns
description: APNS push notification plugin. Uses firebase_messaging on Android, but replaces it on iOS with custom implementation.
version: 1.6.0
version: 1.6.1
homepage: https://github.com/mwaylabs/flutter-apns

plugin:
Expand All @@ -19,7 +19,7 @@ dependencies:
sdk: flutter
firebase_core: ^2.1.1
firebase_messaging: ^14.0.3
flutter_apns_only: ^1.5.2
flutter_apns_only: ^1.6.1

dev_dependencies:
flutter_test:
Expand Down
4 changes: 4 additions & 0 deletions flutter_apns_only/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.6.1
* removed didReceiveRemoteNotification callback since it is deprecated
* resolved invoking onResume twice

## 1.6.0
* upgraded together with flutter_apns main package
* unify version number
Expand Down
24 changes: 3 additions & 21 deletions flutter_apns_only/ios/Classes/FlutterApnsPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,6 @@ func getFlutterError(_ error: Error) -> FlutterError {
channel.invokeMethod("onToken", arguments: deviceToken.hexString)
}


public func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) -> Bool {
let userInfo = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)

if resumingFromBackground {
onResume(userInfo: userInfo)
} else {
channel.invokeMethod("onMessage", arguments: userInfo)
}

completionHandler(.noData)
return true
}

public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo

Expand All @@ -212,8 +198,8 @@ func getFlutterError(_ error: Error) -> FlutterError {
completionHandler([.alert, .sound])
} else {
completionHandler([])
let userInfo = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
self.channel.invokeMethod("onMessage", arguments: userInfo)
let dict = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
self.channel.invokeMethod("onMessage", arguments: dict)
}
}
}
Expand All @@ -232,13 +218,9 @@ func getFlutterError(_ error: Error) -> FlutterError {
return
}

onResume(userInfo: dict)
channel.invokeMethod("onResume", arguments: dict)
completionHandler()
}

func onResume(userInfo: [AnyHashable: Any]) {
channel.invokeMethod("onResume", arguments: userInfo)
}
}

extension UNNotificationCategoryOptions {
Expand Down
2 changes: 1 addition & 1 deletion flutter_apns_only/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_apns_only
description: APNS push notification plugin. Works only on iOS. See flutter_apns for apns & firebase combo
version: 1.6.0
version: 1.6.1
homepage: https://github.com/mwaylabs/flutter-apns

environment:
Expand Down

0 comments on commit 1bb71c8

Please sign in to comment.