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

iOS 15 Feature Notification action icons #991

Merged
merged 5 commits into from
Sep 13, 2021
Merged

Conversation

emawby
Copy link
Contributor

@emawby emawby commented Sep 3, 2021

This is branched off of main which currently has some broken IAM unit tests (already fixed in another PR).

iOS 15 introduced UNNotificationActionIcons (read about them here). This PR supports adding action icons from OneSignal notification payloads.

There are 2 types of icons:

  1. System icons which are SF Symbols included in all iOS Apps.
  2. Template icons which are icon resources included by developers in their app bundles.

Icons can be added to notification actions through a new initializer method, and can themselves be initialized as either system or template icons.


This change is Reviewable

Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @emawby, @Jeasmine, and @nan-li)


iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 577 at r1 (raw file):

            icon = [UNNotificationActionIcon iconWithTemplateImageName:button[@"templateIcon"]];
        }
        return [UNNotificationAction actionWithIdentifier:button[@"id"]

The selector actionWithIdentifier:title:options:icon: is new in the beta version of Xcode:
https://developer.apple.com/documentation/usernotifications/unnotificationaction/3747237-actionwithidentifier?language=objc

We will need to use reflection to call this so it can compile with Xcode 11.0 as we do so to keep bit code compatibility for the release build.

Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @emawby, @Jeasmine, and @nan-li)


iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 580 at r1 (raw file):

                                                    title:button[@"text"]
                                                  options:UNNotificationActionOptionForeground
                                                     icon:icon];

icon might be nil here, not sure if the iOS API is ok with that.

Copy link
Contributor Author

@emawby emawby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @emawby, @Jeasmine, @jkasten2, and @nan-li)


iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 580 at r1 (raw file):

Previously, jkasten2 (Josh Kasten) wrote…

icon might be nil here, not sure if the iOS API is ok with that.

the icon parameter is marked nullable so this should be fine

Copy link
Contributor Author

@emawby emawby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @Jeasmine, @jkasten2, and @nan-li)


iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 577 at r1 (raw file):

Previously, jkasten2 (Josh Kasten) wrote…

The selector actionWithIdentifier:title:options:icon: is new in the beta version of Xcode:
https://developer.apple.com/documentation/usernotifications/unnotificationaction/3747237-actionwithidentifier?language=objc

We will need to use reflection to call this so it can compile with Xcode 11.0 as we do so to keep bit code compatibility for the release build.

Done but its a bit ugly since we cannot use performSelector

@emawby emawby changed the title WiP iOS 15 Feature Notification action icons iOS 15 Feature Notification action icons Sep 13, 2021
Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 4 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Jeasmine and @nan-li)


iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m, line 577 at r1 (raw file):

Previously, emawby (Elliot Mawby) wrote…

Done but its a bit ugly since we cannot use performSelector

no problem, if you think of a better way in the future we can clean it up.

@emawby emawby merged commit a87f4a8 into main Sep 13, 2021
@emawby emawby deleted the feature/notif_action_icons branch September 13, 2021 21:36
@emawby emawby mentioned this pull request Sep 13, 2021
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