[英]How to use same Authenticated user token between main iOS app and its Share Extension
We have the main app integrated with Firebase SDK. 我们有与Firebase SDK集成的主应用程序。 User sign in via main application using email, google or facebook. 用户使用电子邮件,Google或Facebook通过主应用程序登录。
Now, we have share extension implemented which ideally should share same Authentication session internally so that data can be sent on Firebase with the same user without asking him to login again through the extension. 现在,我们实现了共享扩展,理想情况下应该在内部共享同一身份验证会话,以便可以与同一用户在Firebase上发送数据,而无需要求他通过扩展再次登录。
So, does anyone know the way to share Firebase authentication session between the Main app and share extension? 那么,有人知道在主应用程序和共享扩展之间共享Firebase身份验证会话的方式吗?
Either we sent some internal call to the main app to perform Firebase stuff because it has authentication detail within it. 我们要么向内部应用程序发送了一些内部调用以执行Firebase程序,因为其中包含身份验证详细信息。
The main app set some token to common user defaults via app groups which will be then used by Share extension to re-authenticate automatically. 主应用程序通过应用程序组为普通用户默认设置了一些令牌,共享扩展程序将使用这些令牌自动重新进行身份验证。
Or Firebase provide some way to do so, 或Firebase提供了一些方法,
I don't know what is feasible from above. 我不知道什么是可行的。 I found a method signInWithCustomToken:completion:
but, it's not related to what I actually looking for. 我发现了一个方法signInWithCustomToken:completion:
但是它与我实际寻找的内容无关。
To read and save from the same set of NSUserDefaults you need to the the following: 要从同一组NSUserDefaults中读取和保存,您需要执行以下操作:
Write to your NSUserDefaults: 写入您的NSUserDefaults:
// In this example I´m setting FirstLaunch value to true
NSUserDefaults(suiteName: "group.myapp.test")!.setBool(true, forKey: "FirstLaunch")
Read from NSUserDefaults: 从NSUserDefaults读取:
// Getting the value from FirstLaunch
let firstLaunch = NSUserDefaults(suiteName: "group.myapp.test")!.boolForKey("FirstLaunch")
if !firstLaunch {
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.