Ios 对于';没有可见的@界面;推送通知';标记选择器';setdevicetoken:&x27;

Ios 对于';没有可见的@界面;推送通知';标记选择器';setdevicetoken:&x27;,ios,objective-c,cordova,xcode12,Ios,Objective C,Cordova,Xcode12,我是iOS新手,我正在使用Pusher进行通知 我不知道如何修正这个错误 no visible @interface for 'pushnotifications' decalre the selector 'setdevicetoken:' no visible @interface for 'pushnotifications' decalre the selector 'handleNotification:' 这是我的密码: #import "AppDelegate.h&q

我是iOS新手,我正在使用Pusher进行通知

我不知道如何修正这个错误

no visible @interface for 'pushnotifications' decalre the selector 'setdevicetoken:'

no visible @interface for 'pushnotifications' decalre the selector 'handleNotification:'
这是我的密码:

#import "AppDelegate.h"
#import "MainViewController.h"
#import <PushNotifications/PushNotifications.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    self.viewController = [[MainViewController alloc] init];
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

// Add the following as a new method to AppDelegate.m
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  NSLog(@"Registered for remote with token: %@", deviceToken);
  [[PushNotifications alloc] setDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  [[PushNotifications alloc] handleNotification:userInfo];
}

-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
  NSLog(@"Remote notification support is unavailable due to error: %@", error.localizedDescription);
}

@end
#导入“AppDelegate.h”
#导入“MainViewController.h”
#进口
@实现AppDelegate
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项
{
self.viewController=[[MainViewController alloc]init];
return[超级应用程序:应用程序didFinishLaunchingWithOptions:launchOptions];
}
//将以下内容作为新方法添加到AppDelegate.m
-(无效)应用程序:(UIApplication*)应用程序DIdRegisterForRemotionTificationswithDeviceToken:(NSData*)deviceToken{
NSLog(@“为远程注册,令牌为%@”,deviceToken);
[[PushNotifications alloc]setDeviceToken:deviceToken];
}
-(void)application:(UIApplication*)application didReceiveMemotentification:(NSDictionary*)userInfo fetchCompletionHandler:(void(^)(UIBackgroundFetchResult))completionHandler{
[[PushNotifications alloc]handleNotification:userInfo];
}
-(无效)应用程序:(UIApplication*)应用程序未能注册远程通知,错误为:(N错误*)错误{
NSLog(@“远程通知支持因错误而不可用:%@”,错误.localizedDescription);
}
@结束

任何帮助都将不胜感激,谢谢大家。

[[PushNotifications alloc]handleNotification:userInfo]
,alloc+直接调用似乎很奇怪。您正在使用
https://github.com/pusher/push-notifications-swift
?它应该是
共享的
,而不是
分配的
。请参阅示例代码:这很有效!伟大的谢谢你的样品