Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#31, #102 Fixed onResume calling twice #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions flutter_apns_only/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.6.1
* resolved invoking onResume twice

## 1.6.0
* upgraded together with flutter_apns main package
* unify version number
Expand Down
34 changes: 14 additions & 20 deletions flutter_apns_only/ios/Classes/FlutterApnsPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,17 @@ func getFlutterError(_ error: Error) -> FlutterError {
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
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 application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) -> Bool {
let userInfo = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)

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

completionHandler(.noData)
return true
}

public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
Expand All @@ -212,8 +210,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 +230,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