CleverTap / CTNotificationContent

A Notification Content Extension class to display custom content interfaces for iOS 10 push notifications
MIT License
14 stars 7 forks source link

Can open user info for current notifciaton? #2

Closed archerx3 closed 6 years ago

archerx3 commented 6 years ago

In method-didReceiveNotification:(UNNotification *)notification of CTNotificationViewController, we can get the user info for this notification, can open this, let we can get this user info?

Aditi3 commented 6 years ago

Hey @archerx3, sure you can retrieve the userInfo from the method userNotificationCenter(_:didReceive:withCompletionHandler:).

What this will give you is all the User Info details from the userInfo object, the following code snippet will be useful for you:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { // pull out the userInfo dictionary let userInfo = response.notification.request.content.userInfo completionHandler() }

archerx3 commented 6 years ago

But in Notification content extension, can call the methoduserNotificationCenter(_:didReceive:withCompletionHandler:)?

Now, I need get the user info of notification in Notification Content Extension.

archerx3 commented 6 years ago

If I am not wrong, in notification content extension, need use the protocol UNNotificationContentExtension to get notification, but, the base view controller CTNotificationViewController had used it, and not provide them to us.

Aditi3 commented 6 years ago

Hey @archerx3

Apologies for the delay in getting back here.

CleverTap provides a callback that you can implement in your Notification Content Extension subclass to get user event type data

The following code snippet will be useful:

// optional: implement to get user event type data
- (void)userDidPerformAction:(NSString *)action withProperties:(NSDictionary *)properties {
    NSLog(@"user did perform action: %@ with props: %@", action , properties);
}