Cloud Functions for Firebase:你能检测到应用卸载吗?
Cloud Functions for Firebase: can you detect app uninstall?
是否可以在用户卸载应用时触发一个云函数,以便我们清理匿名用户实时数据库条目?
您可以将 Android 的应用程序卸载检测为 automatically collected Analytics event called app_remove
. Then you could trigger a Cloud Function to run when that event occurs. You would also need to use the Firebase Admin SDK to access the database. Check out some of the Cloud Functions for Firebase GitHub samples,以查看使用 Analytics 触发器和使用 Admin SDK 的示例。该函数可以像这样工作:
exports.appUninstall = functions.analytics.event('app_remove').onLog(event => {
const user = event.user; // structure of event was changed
const uid = user.userId; // The user ID set via the setUserId API.
// add code for removing data
});
是否可以在用户卸载应用时触发一个云函数,以便我们清理匿名用户实时数据库条目?
您可以将 Android 的应用程序卸载检测为 automatically collected Analytics event called app_remove
. Then you could trigger a Cloud Function to run when that event occurs. You would also need to use the Firebase Admin SDK to access the database. Check out some of the Cloud Functions for Firebase GitHub samples,以查看使用 Analytics 触发器和使用 Admin SDK 的示例。该函数可以像这样工作:
exports.appUninstall = functions.analytics.event('app_remove').onLog(event => {
const user = event.user; // structure of event was changed
const uid = user.userId; // The user ID set via the setUserId API.
// add code for removing data
});