после этого promising tutorial от nickjf89 Я пытаюсь реализовать Push Notification в проекте Vanilla Cordova.Выполнение PUSER APNs Уведомление
До сих пор я могу получить связь с сокетом, когда я нажимаю данные с консоли Pusher, все работает, поэтому я исключаю любую неверную конфигурацию для API-интерфейса Pusher.
«Единственная» вещь, которая терпит неудачу, является фактическим Push Notification. Глядя на консоль Push Notification, я вижу, что мой запрос поступает на мой канал cordova. Но в консоли xCode я не вижу ожидаемого журнала от NSLog(@"Received remote notification: %@", userInfo);
Я подозреваю, что у меня есть проблема с моим AppDelegate.m
, который находится ниже.
#import "AppDelegate.h"
#import "MainViewController.h"
@import UserNotifications;
#import <PusherSwift/PusherSwift-Swift.h>
@interface AppDelegate()
@property (nonatomic, retain, readwrite) Pusher *pusher;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.viewController = [[MainViewController alloc] init];
self.pusher = [[Pusher alloc] initWithKey:@"here_i_put_my_pusher_app_key"];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionAlert | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) {
// Enable or disable features based on authorisation.
}];
[application registerForRemoteNotifications];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"Registered for remote notifications; received device token");
[[[self pusher] nativePusher] registerWithDeviceToken:deviceToken];
[[[self pusher] nativePusher] subscribeWithInterestName:@"cordova"];
NSLog(@"Seeems token stuff works");
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"Received remote notification: %@", userInfo);
}
@end