我試圖在我的應用程序中實現推送通知。我正在使用APN認證密鑰。到目前爲止,我發現的每個指南都有不贊成使用的方法,或者它在Swift中。我很感興趣像this one但目的C.無法讓推送通知工作
我到目前爲止,做內部AppDelegate.m一個指南:
@import Firebase;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (userInfo) {
[self application:application didReceiveRemoteNotification:userInfo];
}
UIUserNotificationType allNotificationTypes =
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings =
[UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
return YES;
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
// Perform different operations depending on the scenario
if (application.applicationState == UIApplicationStateInactive) {
// Opening the app
NSLog(@"Firebase opening app");
}
else if (application.applicationState == UIApplicationStateBackground) {
// Coming from background
NSLog(@"Firebase background");
}
else {
// Active
NSLog(@"Firebase active");
}
}
不幸的是,當我從火力點發送一條消息我什麼也沒得到,沒有輸出在xcode控制檯中,並沒有通知。 如果您能指出我正確的方向,我將不勝感激。
正是我需要的。感謝隊友 – student
歡迎您。我在自己的最後一個項目中實施了自己,並且100%的工作。順便說一句,不要忘記在firebase中上傳證書(僅適用於iOS,Android不需要它)。我仍然像你一樣在Objective-C上 - 喜歡它!格爾茨 –