Ich wechsle von Facebook iOS SDK zu Facebook Swift SDK.Wechsel von Facebook-ios-sdk zu facebook-swift-sdk, Verwendung von FBSDKAppInviteDialogDelegate im neuen Code
Ich möchte über die Ergebnisse der App Einladung informiert werden. Dies ist, was ich in den alten Code haben:
extension VolumesListViewController: FBSDKAppInviteDialogDelegate {
public func appInviteDialog(_ appInviteDialog: FBSDKAppInviteDialog!, didFailWithError error: Error!) {
...
}
func appInviteDialog(_ appInviteDialog: FBSDKAppInviteDialog!, didCompleteWithResults results: [AnyHashable: Any]!) {
...
}
}
Es scheint, dass in Swift SDK, das DialogDelegate in den Rahmen verkapselt ist und nicht für die Umsetzung geöffnet:
Also, das ist die SDKDelegate:
extension AppInvite {
internal class SDKDelegate: NSObject, FBSDKAppInviteDialogDelegate {
internal var completion: ((Result) -> Void)?
func setupAsDelegateFor(_ dialog: FBSDKAppInviteDialog) {
// We need for the connection to retain us,
// so we can stick around and keep calling into handlers,
// as long as the connection is alive/sending messages.
objc_setAssociatedObject(dialog, Unmanaged.passUnretained(self).toOpaque(), self, .OBJC_ASSOCIATION_RETAIN)
dialog.delegate = self
}
func appInviteDialog(_ appInviteDialog: FBSDKAppInviteDialog?, didCompleteWithResults results: [AnyHashable: Any]?) {
completion?(.success(results?.keyValueFlatMap { ($0 as? String, $1 as? String) } ?? [:]))
}
func appInviteDialog(_ appInviteDialog: FBSDKAppInviteDialog?, didFailWithError error: Error) {
completion?(.failed(error))
}
}
}
Wie erreichen Sie das gleiche mit Benachrichtigungen, ohne das alte Framework zu verwenden?
Mein Grund ist dieser:
Die Rahmenbedingungen für die Facebook-SDK in Swift sind in der gleichen Weise wie das Facebook-SDK für iOS organisiert. Sie hängen auch vom Facebook SDK für iOS ab, obwohl sich das irgendwann in der Zukunft ändern könnte.