我看了很多问题和答案为同一问题。
我现在知道的是
我的情况如下:
我想要的是,当应用程序处于后台或被终止时,我想要得到通知,就像我使用Parse的“自定义受众”时一样。但当我只使用解析的API时,它并没有像我想要的那样工作。
我现在错过什么了吗?
我的注册代码如下:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
NSLog(@"didReceiveRemoteNotification executed : %@",userInfo);
NSInteger bettingIDX = [[userInfo objectForKey:@"betting_idx"] integerValue];
NSString *message = [userInfo objectForKey:@"message"];
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = [NSString stringWithFormat:@"%@",message];
NSUUID *uuid = [NSUUID UUID];
NSString *notificationKey = [uuid UUIDString];
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
NSLog(@"DeviceToken : %@", deviceToken );
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
[Parse setApplicationId:@"applicationID"
clientKey:@"clientID"];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}
使用方法didFinishLaunchingSusOptions
:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
if let launchOptions = launchOptions as? [String: AnyObject],
let userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] as? [String: String] {
}
return true
}
官方留档说:
用户点击警报中的默认按钮或点击(或单击)应用程序图标。如果点击默认操作按钮(在运行iOS的设备上),系统将启动应用程序,应用程序将调用其委托的应用程序:didFinishLaunchingSusOptions:方法,传入通知有效负载(用于远程通知)或本地通知对象(用于本地通知)。尽管应用程序:didFinishLaunchingSusOptions:不是处理通知的最佳位置,但此时获取有效负载使您有机会在调用处理程序方法之前启动更新过程。
我已经集成了Firebase,用于在flutter中推送通知。如果应用程序在前台,我已经显示了一个通知详细信息的对话框。我收到通知正确的Android。同样在iOS通知在后台和设备锁定时工作正常。我还启用了推送通知和后台抓取。对此有什么解决办法吗?有人面临过这样的问题吗? 我使用这个Firebase插件https://pub.dev/packages/firebase_messaging
当应用程序在前台时不接收推送通知,但当应用程序在后台时接收我已遵循来自https://medium . com/@ ankushaggarwal/GCM-setup-for-Android-push-notifications-656 cf DD 8 adbd的FCM教程
关于这个主题有很多stackoverflow线程,但是我仍然没有找到一个好的解决方案。 如果应用程序不在后台,我可以在调用中检查,查看是否从通知中打开。 如果应用程序在后台,所有帖子都建议使用并检查应用程序状态。但正如我所做的实验(也正如这个API的名称所暗示的那样),当收到通知时会调用这个方法,而不是点击。 所以问题是,如果应用程序启动后后台运行,并且您知道从收到通知(此时不会触发),您如何知道
我想在通知屏幕上显示通知,无论应用程序是在后台还是前台。我为寻找解决办法而疲惫不堪。非常感谢任何帮助。
当应用程序在后台时,如何更新包含数据负载的Firebase推送通知?有没有办法在通知中指定通知id给Firebase API? 完整的项目在github https://github.com/akshatashan/FireBaseCloudMessagingDemo中
所以我在firebase消息传递中经历了一个奇怪的行为。我在我的firebase messaging FCM调用中同时发送[通知]和[数据]对象,当应用程序在后台时,我可以接收到我调用FCM请求的多个推送通知。但现在的问题是,当我在打开应用程序时收到推送通知时,如果我点击了该通知,我将不再收到任何进一步的推送通知。 注意:如果我强行停止然后重新打开,我会再次开始收到通知。 我在几个安卓版本的安卓设