facebook-ios-sdk icon indicating copy to clipboard operation
facebook-ios-sdk copied to clipboard

starting with Graph API v2.4, GET requests for /model_asset should contain an explicit "fields" parameter

Open dackArrogant opened this issue 1 year ago • 0 comments

Checklist before submitting a bug report

Xcode version

15.3

Facebook iOS SDK version

17.4.0

Dependency Manager

CocoaPods

SDK Framework

Core

Goals

Call AppLinkUtility.fetchDeferredAppLink {[weak self] (url, error) in if let error = error { print("Error fetching deep link: (error.localizedDescription)") return } if let url = url { let deepLinkUrl = url.absoluteString print("Deferred deep link obtained: (deepLinkUrl)") // Handle deep link _ = self?.handleIncomingURL(url) } else { print("Deep link not obtained") } } Warning starting with Graph API v2.4, GET requests for /model_asset should contain an explicit "fields" parameter

Expected results

starting with Graph API v2.4, GET requests for /model_asset should contain an explicit "fields" parameter AppLinkUtility.fetchDeferredAppLink {[weak self] (url, error) in if let error = error { print("Error fetching deep link: (error.localizedDescription)") return } if let url = url { let deepLinkUrl = url.absoluteString print("获取到的延迟深度链接:(deepLinkUrl)") // 处理深度链接 _ = self?.handleIncomingURL(url) } else { print("未获取到深度链接") } }

Actual results

starting with Graph API v2.4, GET requests for /model_asset should contain an explicit "fields" parameter

Steps to reproduce

starting with Graph API v2.4, GET requests for /model_asset should contain an explicit "fields" parameter

Code samples & details

import UIKit
import FBSDKCoreKit
import AppTrackingTransparency
import AdSupport

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    
    var window: UIWindow?
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
       
        // 在ios15要在这里调用,需要加点延迟
        DispatchQueue.main.asyncAfter(deadline: .now() + 3) { [self] in
            let applicationState = UIApplication.shared.applicationState
            if applicationState == .active {
                requestTrackingAuthorizationAndFetchDeepLink(application, didFinishLaunchingWithOptions: launchOptions)
            }
        }
        
        reachabilityStartNotifier()
        return true
    }
    
    private func requestTrackingAuthorizationAndFetchDeepLink(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
        if #available(iOS 14.0, *) {
            ATTrackingManager.requestTrackingAuthorization { status in
                if status == .authorized {
                    self.fetchDeepLink()
                    
                    let advertisingIdentifier = ASIdentifierManager.shared().advertisingIdentifier
                    if advertisingIdentifier != .init(uuidString: "00000000-0000-0000-0000-000000000000")! {
                        print("广告标识: \(advertisingIdentifier)")
                    } else {
                        print("广告标识不可用")
                    }
                } else {
                    print("Tracking authorization not granted. Deferred deep linking may not work.")
                }
            }
        } else {
            fetchDeepLink()
        }
    }
    
    private func fetchDeepLink() {
        Settings.shared.isAdvertiserIDCollectionEnabled = true
        Settings.shared.isSKAdNetworkReportEnabled = true
        ApplicationDelegate.shared.initializeSDK()
        AppLinkUtility.fetchDeferredAppLink {[weak self] (url, error) in
            if let error = error {
                print("Error fetching deep link: \(error.localizedDescription)")
                return
            }
            if let url = url {
                let deepLinkUrl = url.absoluteString
                print("获取到的延迟深度链接:\(deepLinkUrl)")
                // 处理深度链接
               _ = self?.handleIncomingURL(url)
            } else {
                print("未获取到深度链接")
            }
        }
    }
    
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
        // 处理传入的URL
        return handleIncomingURL(url)
    }
    
     func handleIncomingURL(_ url: URL) -> Bool {
        // 解析URL并根据需要执行操作
        print("处理传入的URL: \(url.absoluteString)")
        
        // 示例:根据URL路径或参数进行不同的处理
        if let components = URLComponents(url: url, resolvingAgainstBaseURL: false) {
            // 解析路径或查询参数
            if components.path == "/somePath" {
                // 处理特定路径
                print("处理特定路径: \(components.path)")
                // 在这里导航到对应的视图控制器
                return true
            }
        }
        
        return false
    }
}

extension AppDelegate {
    private func reachabilityStartNotifier() {
        let reach = Reachability()!
        NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(note:)), name: .reachabilityChanged, object: reach)
        do {
            try reach.startNotifier()
        } catch {}
    }
    
    @objc public func reachabilityChanged(note _: Notification) {}
}

dackArrogant avatar Nov 04 '24 06:11 dackArrogant