【发布时间】:2017-07-27 13:50:37
【问题描述】:
我可以在应用关闭时运行 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];
}];
}
【问题讨论】:
标签: ios objective-c firebase firebase-realtime-database firebase-notifications