0
Firebaseを使用してトピックを登録し、iOSデバイスでプッシュ通知を送信しています。 iPhone 4(iOS 7)以外はすべて正常に動作していますが、通知は受けません。FCMトピック - iPhone 4(iOS 7)で通知が受信されない
iPhone 4(iOS 7)を含むすべてのデバイスに単一のデバイス通知を送信できますが、この問題はトピックプッシュ通知でのみ発生します。下の私のコード。
-(void)application:(UIApplication)application didRegisterUserNotificationSettings:(UIUserNotificationSettings)notificationSettings
{
[[FIRMessaging messaging] subscribeToTopic:@"/topics/mytopic"];
[application registerForRemoteNotifications];
}
-(BOOL)application:(UIApplication)application didFinishLaunchingWithOptions:(NSDictionary)launchOptions
{
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// iOS 8 Notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshCallback:) name:kFIRInstanceIDTokenRefreshNotification object:nil];
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}
else
{
// iOS < 8 Notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshCallback:) name:kFIRInstanceIDTokenRefreshNotification object:nil];
[[FIRMessaging messaging] subscribeToTopic:@"/topics/mytopic"];
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
}
ためthiseを使うのか? – Hya
[[FIRMessaging messaging] subscribeToTopic:@ "/ topics/news"]; –
は、[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification :) name:kFIRInstanceIDTokenRefreshNotificationオブジェクト:nil]でエラーを返します。 – Hya