revert native changes
This commit is contained in:
@@ -66,7 +66,6 @@ module.exports = function (_config) {
|
|||||||
infoPlist: {
|
infoPlist: {
|
||||||
CADisableMinimumFrameDurationOnPhone: true,
|
CADisableMinimumFrameDurationOnPhone: true,
|
||||||
UIBackgroundModes: ['remote-notification'],
|
UIBackgroundModes: ['remote-notification'],
|
||||||
NSUserActivityTypes: ['INSendMessageIntent'],
|
|
||||||
NSCameraUsageDescription:
|
NSCameraUsageDescription:
|
||||||
'Used for profile pictures, posts, and other kinds of content.',
|
'Used for profile pictures, posts, and other kinds of content.',
|
||||||
NSMicrophoneUsageDescription:
|
NSMicrophoneUsageDescription:
|
||||||
@@ -124,7 +123,6 @@ module.exports = function (_config) {
|
|||||||
'com.apple.developer.kernel.increased-memory-limit': true,
|
'com.apple.developer.kernel.increased-memory-limit': true,
|
||||||
'com.apple.developer.kernel.extended-virtual-addressing': true,
|
'com.apple.developer.kernel.extended-virtual-addressing': true,
|
||||||
'com.apple.security.application-groups': 'group.app.bsky',
|
'com.apple.security.application-groups': 'group.app.bsky',
|
||||||
'com.apple.developer.usernotifications.communication': true,
|
|
||||||
// 'com.apple.developer.device-information.user-assigned-device-name': true,
|
// 'com.apple.developer.device-information.user-assigned-device-name': true,
|
||||||
},
|
},
|
||||||
privacyManifests: {
|
privacyManifests: {
|
||||||
|
|||||||
@@ -8,13 +8,6 @@
|
|||||||
<string>com.apple.usernotifications.service</string>
|
<string>com.apple.usernotifications.service</string>
|
||||||
<key>NSExtensionPrincipalClass</key>
|
<key>NSExtensionPrincipalClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).NotificationService</string>
|
<string>$(PRODUCT_MODULE_NAME).NotificationService</string>
|
||||||
<key>NSExtensionAttributes</key>
|
|
||||||
<dict>
|
|
||||||
<key>IntentsSupported</key>
|
|
||||||
<array>
|
|
||||||
<string>INSendMessageIntent</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
</dict>
|
||||||
<key>MainAppScheme</key>
|
<key>MainAppScheme</key>
|
||||||
<string>bluesky</string>
|
<string>bluesky</string>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import UserNotifications
|
import UserNotifications
|
||||||
import UIKit
|
import UIKit
|
||||||
import Intents
|
|
||||||
|
|
||||||
let APP_GROUP = "group.app.bsky"
|
let APP_GROUP = "group.app.bsky"
|
||||||
typealias ContentHandler = (UNNotificationContent) -> Void
|
typealias ContentHandler = (UNNotificationContent) -> Void
|
||||||
@@ -41,18 +40,17 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.bestAttempt = bestAttempt
|
self.bestAttempt = bestAttempt
|
||||||
|
if reason == "chat-message" {
|
||||||
if reason == "chat-message" || reason == "chat-reaction" {
|
|
||||||
mutateWithChatMessage(bestAttempt)
|
mutateWithChatMessage(bestAttempt)
|
||||||
let finalContent = createCommunicationNotification(
|
|
||||||
from: bestAttempt,
|
|
||||||
userInfo: request.content.userInfo
|
|
||||||
)
|
|
||||||
contentHandler(finalContent)
|
|
||||||
} else {
|
} else {
|
||||||
mutateWithBadge(bestAttempt)
|
mutateWithBadge(bestAttempt)
|
||||||
contentHandler(bestAttempt)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Any image downloading (or other network tasks) should be handled at the end
|
||||||
|
// of this block. Otherwise, if there is a timeout and serviceExtensionTimeWillExpire
|
||||||
|
// gets called, we might not have all the needed mutations completed in time.
|
||||||
|
|
||||||
|
contentHandler(bestAttempt)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func serviceExtensionTimeWillExpire() {
|
override func serviceExtensionTimeWillExpire() {
|
||||||
@@ -63,81 +61,6 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
contentHandler(bestAttempt)
|
contentHandler(bestAttempt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Communication Notification
|
|
||||||
|
|
||||||
func createCommunicationNotification(
|
|
||||||
from content: UNMutableNotificationContent,
|
|
||||||
userInfo: [AnyHashable: Any]
|
|
||||||
) -> UNNotificationContent {
|
|
||||||
let senderDisplayName = userInfo["senderDisplayName"] as? String ?? "Unknown"
|
|
||||||
let convoId = userInfo["convoId"] as? String
|
|
||||||
var avatarImage: INImage? = nil
|
|
||||||
if let avatarUrlString = userInfo["senderAvatarUrl"] as? String {
|
|
||||||
avatarImage = downloadAvatarImage(from: avatarUrlString)
|
|
||||||
}
|
|
||||||
|
|
||||||
let senderHandleValue = userInfo["senderHandle"] as? String
|
|
||||||
let senderHandle = INPersonHandle(value: senderHandleValue, type: .unknown)
|
|
||||||
let sender = INPerson(
|
|
||||||
personHandle: senderHandle,
|
|
||||||
nameComponents: nil,
|
|
||||||
displayName: senderDisplayName,
|
|
||||||
image: avatarImage,
|
|
||||||
contactIdentifier: nil,
|
|
||||||
customIdentifier: nil
|
|
||||||
)
|
|
||||||
|
|
||||||
let intent = INSendMessageIntent(
|
|
||||||
recipients: nil,
|
|
||||||
outgoingMessageType: .outgoingMessageText,
|
|
||||||
content: content.body,
|
|
||||||
speakableGroupName: nil,
|
|
||||||
conversationIdentifier: convoId,
|
|
||||||
serviceName: nil,
|
|
||||||
sender: sender,
|
|
||||||
attachments: nil
|
|
||||||
)
|
|
||||||
|
|
||||||
let interaction = INInteraction(intent: intent, response: nil)
|
|
||||||
interaction.direction = .incoming
|
|
||||||
interaction.donate(completion: nil)
|
|
||||||
|
|
||||||
do {
|
|
||||||
return try content.updating(from: intent)
|
|
||||||
} catch {
|
|
||||||
return content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func downloadAvatarImage(from urlString: String) -> INImage? {
|
|
||||||
let thumbnailUrlString = urlString.replacingOccurrences(
|
|
||||||
of: "/img/avatar/",
|
|
||||||
with: "/img/avatar_thumbnail/"
|
|
||||||
)
|
|
||||||
|
|
||||||
guard let url = URL(string: thumbnailUrlString) else { return nil }
|
|
||||||
|
|
||||||
var request = URLRequest(url: url)
|
|
||||||
request.timeoutInterval = 5
|
|
||||||
|
|
||||||
var imageData: Data? = nil
|
|
||||||
let semaphore = DispatchSemaphore(value: 0)
|
|
||||||
|
|
||||||
let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
|
||||||
if let data = data,
|
|
||||||
let httpResponse = response as? HTTPURLResponse,
|
|
||||||
httpResponse.statusCode == 200 {
|
|
||||||
imageData = data
|
|
||||||
}
|
|
||||||
semaphore.signal()
|
|
||||||
}
|
|
||||||
task.resume()
|
|
||||||
semaphore.wait()
|
|
||||||
|
|
||||||
guard let data = imageData else { return nil }
|
|
||||||
return INImage(imageData: data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: Mutations
|
// MARK: Mutations
|
||||||
|
|
||||||
func mutateWithBadge(_ content: UNMutableNotificationContent) {
|
func mutateWithBadge(_ content: UNMutableNotificationContent) {
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ class BackgroundNotificationHandler(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remoteMessage.data["reason"] == "chat-message" || remoteMessage.data["reason"] == "chat-reaction") {
|
if (remoteMessage.data["reason"] == "chat-message") {
|
||||||
mutateWithChatMessage(remoteMessage)
|
mutateWithChatMessage(remoteMessage)
|
||||||
} else {
|
} else {
|
||||||
mutateWithOtherReason(remoteMessage)
|
mutateWithOtherReason(remoteMessage)
|
||||||
|
|||||||
Reference in New Issue
Block a user