-
Notifications
You must be signed in to change notification settings - Fork 264
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] API Updates #1255
Merged
Merged
[5.0.0] API Updates #1255
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* addTrigger and addTriggers public API will only accept string values, not types string/bool/number, etc. * No logic changes are needed as the SDK already supports string-only trigger values and evaluates booleans and numerics correctly. Tested scenarios with these triggers set via the dashboard on IAMs: 🟢 myTrigger is true 🟡 myTrigger is 1.58 (must pass in "1.58" and not "1.580" for example, the "is" operator does not support numeric equivalence, it arrives to the SDK as value "1.58") 🟢 myTrigger > 5 🟢 myTrigger > 7.689 🟡 myTrigger >= 7.689 (note margin of error due to rounding, this value actually came to the SDK as 7.689000129699707, so adding a trigger value of "7.689" does not trigger the IAM to display)
* Make Live Activities namespace `OneSignal.LiveActivities`
* Rename `requiresPrivacyConsent` to `consentRequired` * Rename `privacyConsent` to `consentGiven` * Remove public getters for these 2 properties * Swift cannot have computed write-only properties so instead of `OneSignal.consentGiven = true`, it will be `OneSignal.setConsentGiven(true)`
* Add permissionNative which tells if it's provisional, ephemeral, denied, authorized etc * Expose enum OSNotificationPermission which has 5 values
* These are already part of the OSDebug protocol so no need to state them again
* For Swift, no capitalizing the paused boolean: it will be OneSignal.InAppMessages.paused instead of capital Paused.
* Rename observer from `OSPermissionObserver` to `OSNotificationPermissionObserver` * Rename and change the method from `onOSPermissionChanged:(OSPermissionStateChanges)` to `onNotificationPermissionDidChange:(BOOL)` * The `OSObservable` infrastructure works with objects, and even though we use NSNumber to get around this, once we pass an NSNumber to the app developer's method that expects a BOOL, it does not work. * Therefore, make another OSBoolObservable just for booleans, and use `NSInvocation` instead of `performSelector` because the latter only works with objects.
* Rename `OSInAppMessageLifecycleHandler` to `OSInAppMessageLifecycleListener` * The methods will receive specific event types such as `OSInAppMessageDidDisplayEvent` instead of just the `OSInAppMessage` * Add a remove method `removeLifecycleListener` * Due to Obj-C not allowing method overloading, add `InAppMessage` to method names, so it doesn't conflict with Notifications displays, but this doesn't apply to Swift as we can refine the swift name. - onWillDisplayInAppMessage - onDidDisplayInAppMessage - onWillDismissInAppMessage - onDidDismissInAppMessage
* Rename notificationWillShowInForegroundHandler to OSNotificationLifecycleListener * It will have the `onWillDisplay` event.
* 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
* It can just use the `wantsToDisplay` property of the notification it owns.
* 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
[5.0.0] IAM Click Listener - API update
…ver_api [5.0.0] Push Subscription Observer - API update
…_listener_api [5.0.0] Notification Foreground Listener - API update
[5.0.0] IAM Lifecycle Listener - API update
…_observer_api [5.0.0] Notification Permission Observer - API update
emawby
changed the title
[5.0.0] API Updates (no listeners or handlers)
[5.0.0] API Updates
May 1, 2023
emawby
approved these changes
May 1, 2023
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
API updates for the changes not related to observer/handler/listener changes.
Details
Motivation
A desire to align terminologies and naming conventions across the OneSignal SDKs.
Details
The changes are split up into individual commits for more details of each change.
1. API for adding triggers has string values
addTrigger
andaddTriggers
public API will only acceptstring
values, not types string/bool/number, etc.2. Make Live Activities namespace
OneSignal.LiveActivities
3. Update privacy consent API names and no public getters
requiresPrivacyConsent
toconsentRequired
privacyConsent
toconsentGiven
OneSignal.consentGiven = true
, it will beOneSignal.setConsentGiven(true)
4. Add OneSignal.Notifications.permissionNative
permissionNative
to Notifications namespace which tells if it's provisional, ephemeral, denied, authorized etcOSNotificationPermission
which has these 5 values5. Update InAppMessages.paused to not be capitalized
OneSignal.InAppMessages.paused
instead ofOneSignal.InAppMessages.Paused
.Testing
Manual testing
Physical iPhone 13 on iOS 16.x.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is