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

[Fix] swizzle of deprecated didReceiveRemoteNotification #1094

Merged

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented May 24, 2022

Description

One Line Summary

Fix application:didReceiveRemoteNotification: not being called on iOS 10+, due to OneSignal adding application:didReceiveRemoteNotification:fetchCompletionHandler:.

Details

Motivation

This is a long standing bug on a very deprecated selector, however OneSignal should not cause any side effects when possible. Priority was put resolving shortly after discovering as it is easier to address while it fresh in the mind of those who are working on some unrelated but recent swizzling fixes.

Scope

Only effects apps that use application:didReceiveRemoteNotification: but uses none of the other notification selectors in their AppDelegate AND also have not setup their own UNUserNotificationCenterDelegate.

Clean up

Also in this PR is cleaning up oneSignalReceivedRemoteNotification, since it was only required to support iOS 6 and older.

Testing

Unit testing

Added a new test.

Manual testing

Tested on an iPhone 6s with iOS 14.4.1. Tested with both a SwiftUI app and Objective-C app.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
    • Swizzling
  • 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

While didReceiveRemoteNotification has been deprecated for a while there
may still be some older apps still expecting this to be called and
OneSignal should not cause any side effects.
Apple's iOS logic is both didReceiveRemoteNotification and
didReceiveRemoteNotification:fetchCompletionHandler are defined only the
newer API will be called. This means OneSignal must also replicate this
logic to prevent side effects.
https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623117-application?language=objc

Also removed our swizzling on didReceiveRemoteNotification as we no
longer support iOS 6. Apple added
application:didReceiveRemoteNotification:fetchCompletionHandler: in iOS
7 so we could have dropped this swizzling awhile ago.
@jkasten2 jkasten2 requested review from emawby and a team May 24, 2022 23:51
@jkasten2 jkasten2 changed the title [Fix] swizzle forwarding deprecated didReceiveRemoteNotification [Fix] swizzle of deprecated didReceiveRemoteNotification May 25, 2022
@jkasten2 jkasten2 merged commit 298ef31 into main May 26, 2022
@jkasten2 jkasten2 deleted the fix/swizzle_forwarding_deprecated_didReceiveRemoteNotification branch May 26, 2022 04:29
@emawby emawby mentioned this pull request Jun 16, 2022
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