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] Push Subscription Observer - API update #1260

Conversation

nan-li
Copy link
Contributor

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

Description

One Line Summary

Push Subscription Observer - API update.

Details

Motivation

Push Subscription Observer - API update.

Scope

  • Rename OSPushSubscriptionStateChanges to OSPushSubscriptionChangedState
  • Rename event from onOSPushSubscriptionChanged to onPushSubscriptionDidChange
  • Use current and previous instead of to and from
  • No other logic changes, only naming

Public API

OneSignal.User.pushSubscription namespace
    func addObserver(_ observer: OSPushSubscriptionObserver)
    func removeObserver(_ observer: OSPushSubscriptionObserver)
protocol OSPushSubscriptionObserver {
    func onPushSubscriptionDidChange(state: OSPushSubscriptionChangedState)
}
class OSPushSubscriptionChangedState
    let current: OSPushSubscriptionState
    let previous: OSPushSubscriptionState
    func jsonRepresentation() -> NSDictionary 

Testing

Manual testing

Tested on Physical iPhone 13 with iOS 16.x

  • AppDelegate and messaging controller and live activities controllers' callbacks fire when the push subscription changes

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 OSPushSubscriptionStateChanges to OSPushSubscriptionChangedState
* Rename event from onOSPushSubscriptionChanged to onPushSubscriptionDidChange
* Use current and previous instead of to and from
* No other logic changes, only naming
@nan-li nan-li requested review from emawby, jkasten2, shepherd-l and jennantilla and removed request for emawby April 28, 2023 20:41
nan-li and others added 6 commits April 28, 2023 17:54
* Rename click block to `OSInAppMessageClickListener`
* Rename `setClickHandler` to  `addClickListener`
* Add a remove method for the click listener
* OSInAppMessageAction has basically been renamed to OSInAppMessageClickResult
* OSInAppMessageClickEvent will be passed to developers instead of OSInAppMessageAction and the event will contain an in app message and a click result.
OSInAppMessageDelegate  and handleMessageAction not used by anything
* We have some legacy logic about IAM direct influence but if there are multiple click listeners added, we only want this to update once, and not for every listener.
* Rename setNotificationOpenedHandler -> addClickListener, removeClickListener
* Rename object `OSNotificationOpenedResult` -> `OSNotificationClickEvent`
* Rename object `OSNotificationAction` -> `OSNotificationClickResult`
* Support having multiple listeners
…ener_api

[5.0.0] Notification Click Listener - API update
@emawby emawby merged commit d3613e2 into 5.0.0/notification_foreground_listener_api May 1, 2023
@emawby emawby deleted the 5.0.0/push_subscription_observer_api branch May 1, 2023 20:25
@emawby emawby mentioned this pull request May 1, 2023
nan-li pushed a commit that referenced this pull request Oct 30, 2023
…ver_api

[5.0.0] Push Subscription Observer - API update
nan-li pushed a commit that referenced this pull request Oct 30, 2023
…ver_api

[5.0.0] Push Subscription Observer - 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