0
当应用程序关闭时,我可以运行Firebase侦听程序,以便我可以使用后端来推送本地通知以发送通知 也可以自动从Firebase推送通知取决于更改在数据库 火力的我跑它回地面,所以我可以推当应用程序关闭时,将Firebase侦听程序保留在内存中
- (void)applicationDidEnterBackground:(UIApplication *)application {
FIRDatabaseReference *ref = [[FIRDatabase database]reference];
[[[ref child:@"classes"]child:@"classA"]observeEventType:FIRDataEventTypeChildChanged withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
FIRDataSnapshot *child;
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil) return;
NSDate *fireTime = [[NSDate date] addTimeInterval:3];
localNotif.fireDate = fireTime;
localNotif.alertBody = @"Alert! from back ground";
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}];
}
好的,谢谢 但现在我的问题是有没有去从火力点自动发布通知取决于数据库的变化,从控制台 通知跑好 –
哦,在这种情况下,你应该尝试使用火力地堡上触发的功能。以下是可帮助您开始使用的示例:https://github.com/firebase/functions-samples/tree/master/fcm-notifications – TawaNicolas