我试图在我的应用程序中实现推送通知。我正在使用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上 - 喜欢它!格尔茨 –