gpt4 book ai didi

ios - FitBit 集成,允许权限后 safari 不会重定向到应用程序

转载 作者:行者123 更新时间:2023-11-29 11:52:48 24 4
gpt4 key购买 nike

我是 iOS 开发新手。我正在尝试将 Fitbit 集成到我的应用程序中。我关注了get authorization from Fitbit using Oauth in iOS和 FitBit 文档。我使用了以下代码

- (IBAction)fitbitLogin:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=xyxyxy&redirect_uri=xxxxx&scope=activity%20nutrition%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight"]];

}

它启动了 Safari 应用程序,我填写了我的凭据并点击允许意味着 Safari 中显示错误,如“Safari 无法打开页面,因为地址无效”。我是 iOS 开发的新手,不知道如何进行下一步。有人可以帮我解决这个问题吗?提前致谢。

最佳答案

在 AppDelegate 中添加以下功能解决了我的问题,希望它也适用于您。

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let notification = Notification(name: Notification.Name(rawValue: "NotificationString"), object: nil, userInfo: [UIApplicationLaunchOptionsKey.url:url])
NotificationCenter.default.post(notification)
return true
}

关于ios - FitBit 集成,允许权限后 safari 不会重定向到应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40418709/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com