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

[5.0.0] Notification Click Listener - API update #1262

Merged

Conversation

nan-li
Copy link
Contributor

@nan-li nan-li commented Apr 30, 2023

Description

One Line Summary

Notification Click Listener - API update

Details

Motivation

Notification Click Listener - API update

Scope

  • Rename API around setNotificationOpenedHandler -> addClickListener, removeClickListener
  • Also support adding multiple listeners, and removal.
  • Rename object OSNotificationOpenedResult -> OSNotificationClickEvent
  • Rename object OSNotificationAction -> OSNotificationClickResult
  • Some small properties changes on those interfaces.

Public API

OneSignal.Notifications namespace
    + (void)addClickListener:(NSObject<OSNotificationClickListener>*_Nonnull)listener
    + (void)removeClickListener:(NSObject<OSNotificationClickListener>*_Nonnull)listener
OSNotificationClickListener
    - (void)onClickNotification:(OSNotificationClickEvent *_Nonnull)event
    func onClick(event: OSNotificationClickEvent) // For Swift API refined
OSNotificationClickEvent
    @property(readonly, nonnull)OSNotification* notification
    @property(readonly, nonnull)OSNotificationClickResult *result
    - (NSString* _Nonnull)stringify
    - (NSDictionary *_Nonnull)jsonRepresentation
OSNotificationClickResult
    @property(readonly, nullable)NSString* actionId
    @property(readonly, nullable)NSString* url

Testing

Manual testing

Test on physical iPhone 13 with iOS 16.x

  • tested adding multiple click listeners and their removal
  • tested accessing properties of the objects
  • tested that click events are saved if there are no click listeners and then once a click listener is added, it is fired with the saved click events (existing behavior pre-user model).

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

This change is Reviewable

* Rename setNotificationOpenedHandler -> addClickListener, removeClickListener
* Rename object `OSNotificationOpenedResult` -> `OSNotificationClickEvent`
* Rename object `OSNotificationAction` -> `OSNotificationClickResult`
* Support having multiple listeners
@nan-li nan-li changed the title Notification Click Listener - API update [5.0.0] Notification Click Listener - API update Apr 30, 2023
@emawby emawby merged commit 553d31c into 5.0.0/iam_click_listener_api May 1, 2023
@emawby emawby deleted the 5.0.0/notification_click_listener_api branch May 1, 2023 20:02
@emawby emawby mentioned this pull request May 1, 2023
nan-li pushed a commit that referenced this pull request Oct 30, 2023
…ener_api

[5.0.0] Notification Click Listener - API update
nan-li pushed a commit that referenced this pull request Oct 30, 2023
…ener_api

[5.0.0] Notification Click Listener - API update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants