I need to capture data from payload when recive a remote push notification, on IOS 9 i did this using the func: didReceiveRemoteNotification On IOS 10 using swift 3.0 i've implemented this 2 functions.
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
print("\(notification.request.content.userInfo)")
completionHandler([.alert, .badge, .sound])
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
{
print("User Info = ",response.notification.request.content.userInfo)
completionHandler()
}
the second fuction only executes when the user touch the push
i need capture data when a push notification arrives while my app is in background or even closed.
Regards. greetings
Push payloads are sent with encrypted content when the mobile app supplies an RSA public encryption key upon push registration with the Salesforce push notification service. When a payload is sent from a customer org to a user's device, the mobile app processes and decrypts the payload.
The payload contains any custom data that you want to send to your app and includes information about how the system should notify the user. You construct this payload as a JSON dictionary and send it as the body content of your HTTP/2 message.
Android 12(vanilla/stock) Collapsed notification: body - 43 characters(1 line), header - 39 characters(1 line) Extended notification: body - 504 characters(10 lines), header - 79 characters(2 lines) Notification with banner(image): body - 96 characters(2 lines), header -79 characters(2 lines)
When a push notification is received and your app isn't running, you need to implement your notification logic in didFinishLaunchingWithOptions:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Called when a notification is tapped and the app wasn't running, not in foreground neither in background.
if let userInfo = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? [String: AnyObject]{
// your logic here!
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With