适用于react-native应用程序中Firebase日志的iOS 14.5 App跟踪透明度 [英] iOS 14.5 App Tracking Transparency for firebase logs in react-native app
本文介绍了适用于react-native应用程序中Firebase日志的iOS 14.5 App跟踪透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Firebase日志在我正在使用的 react-native
应用程序之一更新到 iOS 14.5
后立即停止工作.
Firebase logs stopped working as soon as updated to iOS 14.5
for one of the react-native
app I am working on.
要使其重新工作,我们需要做哪些必要的更改?
What are the necessary changes that we need to do to make it working again?
推荐答案
您需要先请求跟踪权限(我使用react-native-permissions):
You need to request Tracking permissions first (I used react-native-permissions):
import { request, RESULTS, PERMISSIONS } from 'react-native-permissions'
import { Settings } from 'react-native-fbsdk-next'
export const requestPermissionTransparency = async () => {
return await request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)
}
useEffect(() => {
;(async () => {
const result = await requestPermissionTransparency()
if (result === PERMISSION_RESULTS.GRANTED) {
await firebase.analytics().setAnalyticsCollectionEnabled(true)
await Settings.setAdvertiserTrackingEnabled(true)
} else {
await firebase.analytics().setAnalyticsCollectionEnabled(false)
await Settings.setAdvertiserTrackingEnabled(false)
}
})()
}, [])
记住要在根项目中添加此文件:
Remember to add this file in the root project:
// <project-root>/firebase.json
{
"react-native": {
"analytics_auto_collection_enabled": false
}
}
参考文献: https://rnfirebase.io/analytics/usage
这篇关于适用于react-native应用程序中Firebase日志的iOS 14.5 App跟踪透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文