forked from parse-community/Parse-Swift
-
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Support Apple push live activity notifications #184
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
Draft
cbaker6
wants to merge
8
commits into
main
Choose a base branch
from
liveActivity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8a5fe1a
fix: Apple push notificaiton not working for live activities
cbaker6 093542e
lint
cbaker6 6b7a435
Merge branch 'main' into liveActivity
cbaker6 57c0d44
Merge branch 'main' into liveActivity
cbaker6 b7489c5
WIP
cbaker6 940ff5a
Merge branch 'main' into liveActivity
cbaker6 2385404
Merge branch 'main' into liveActivity
cbaker6 24c9d60
Merge branch 'main' into liveActivity
cbaker6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // | ||
| // ParsePushApplePayload.swift | ||
| // ParseSwift | ||
| // | ||
| // Created by Corey Baker on 9/16/24. | ||
| // Copyright © 2024 Network Reconnaissance Lab. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| // swiftlint:disable line_length | ||
|
|
||
| protocol ParsePushAppleHeader { | ||
|
|
||
| /** | ||
| The unique ID for the notification. | ||
| */ | ||
| var id: UUID? { get set } | ||
| /** | ||
| The unique ID for this request. | ||
| - note: Used for broadcast push notifications. | ||
| */ | ||
| var requestId: UUID? { get set } | ||
| /** | ||
| A base64-encoded string that identifies the channel to publish the payload. | ||
| The channel ID is generated by sending channel creation request to APNs. | ||
| - note: Used for broadcast push notifications. | ||
| */ | ||
| var channelId: String? { get set } | ||
| /** | ||
| Multiple notifications with same collapse identifier are displayed to the user as a single | ||
| notification. The value should not exceed 64 bytes. | ||
| */ | ||
| var collapseId: String? { get set } | ||
| /** | ||
| The priority of the notification. Specify 10 to send the notification immediately. | ||
| Specify 5 to send the notification based on power considerations on the user’s device. | ||
| See Apple's [documentation](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns) | ||
| for more information. | ||
| - warning: For Apple OS's only. | ||
| */ | ||
| var priority: Int? { get set } | ||
| /** | ||
| The destination topic for the notification. | ||
| */ | ||
| var topic: String? { get set } | ||
| /** | ||
| The type of the notification. The value is alert or background. Specify alert when the | ||
| delivery of your notification displays an alert, plays a sound, or badges your app’s icon. | ||
| Specify background for silent notifications that do not interact with the user. | ||
| Defaults to alert if no value is set. | ||
| - warning: Required when delivering notifications to | ||
| devices running iOS 13 and later, or watchOS 6 and later. Ignored on earlier OS versions. | ||
| */ | ||
| var pushType: ParsePushPayloadApple.PushType? { get set } | ||
| } | ||
|
|
||
| public protocol ParsePushApplePayload: ParsePushApplePayloadable { | ||
| /** | ||
| The background notification flag. If you are a writing an app using the Remote Notification | ||
| Background Mode introduced in iOS7 (a.k.a. “Background Push”), set this value to | ||
| 1 to trigger a background update. For more informaiton, see [Apple's documentation](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app). | ||
| - warning: For Apple OS's only. You also have to set `pushType` starting iOS 13 | ||
| and watchOS 6. | ||
| */ | ||
| var contentAvailable: Int? { get set } | ||
| /** | ||
| The notification service app extension flag. Set this value to 1 to trigger the system to pass the notification to your notification service app extension before delivery. Use your extension to modify the notification’s content. For more informaiton, see [Apple's documentation](https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications). | ||
| - warning: You also have to set `pushType` starting iOS 13 | ||
| and watchOS 6. | ||
| */ | ||
| var mutableContent: Int? { get set } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // | ||
| // ParsePushNotificationBody.swift | ||
| // ParseSwift | ||
| // | ||
| // Created by Corey Baker on 9/17/24. | ||
| // Copyright © 2024 Network Reconnaissance Lab. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct ParsePushNotificationBody: ParseTypeable { | ||
| var `where`: QueryWhere? | ||
| var channels: Set<String>? | ||
| var data: AnyCodable? | ||
| var pushTime: Date? | ||
| var expirationTime: TimeInterval? | ||
| var expirationInterval: Int? | ||
|
|
||
| enum CodingKeys: String, CodingKey { | ||
| case pushTime = "push_time" | ||
| case expirationTime = "expiration_time" | ||
| case expirationInterval = "expiration_interval" | ||
| case `where`, channels, data | ||
| } | ||
|
|
||
| init<T: ParsePushApplePayload>(push: ParsePush<T>) { | ||
| self.where = push.where | ||
| self.channels = push.channels | ||
| self.pushTime = push.pushTime | ||
| self.expirationTime = push.expirationTime | ||
| self.expirationInterval = push.expirationInterval | ||
| if let payload = push.payload { | ||
| self.data = AnyCodable( | ||
| ParsePushAppleNotification(payload: payload) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| init<T: ParsePushPayloadable>(push: ParsePush<T>) { | ||
| self.where = push.where | ||
| self.channels = push.channels | ||
| self.pushTime = push.pushTime | ||
| self.expirationTime = push.expirationTime | ||
| self.expirationInterval = push.expirationInterval | ||
| if let payload = push.payload { | ||
| self.data = AnyCodable( | ||
| payload | ||
| ) | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 129
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 6648
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 255
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 112
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 108
🏁 Script executed:
git show 24c9d60:./Sources/ParseSwift/Protocols/ParsePushApplePayloadable.swift | head -100Repository: netreconlab/Parse-Swift
Length of output: 4977
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 2097
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 227
🏁 Script executed:
git log --all --oneline -- ./Sources/ParseSwift/Protocols/ParsePushApplePayloadable.swift | head -5Repository: netreconlab/Parse-Swift
Length of output: 237
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 49
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 4058
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 1081
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 598
🏁 Script executed:
git diff 51a44ef..HEAD -- ./Sources/ParseSwift/Protocols/ParsePushApplePayloadable.swift | head -150Repository: netreconlab/Parse-Swift
Length of output: 4392
🏁 Script executed:
cat -n ./Sources/ParseSwift/Types/ParsePushPayload/ParsePushPayloadAny.swift | head -80Repository: netreconlab/Parse-Swift
Length of output: 3160
🏁 Script executed:
Repository: netreconlab/Parse-Swift
Length of output: 49
Source-breaking changes to public protocol require careful consideration!
Adding
contentAvailable,mutableContent, andinit()as new requirements to the publicParsePushApplePayloadableprotocol breaks external conformers. This is a legitimate source-breaking change. If this isn't accompanied by a major-version bump, consider moving these requirements toParsePushApplePayloadinstead, or introduce them as an opt-in protocol to maintain backward compatibility. I'm ready to help draft an alternative approach that keeps the protocol stable!🤖 Prompt for AI Agents