nach diesem promising tutorial von nickjf89 Ich versuche Push-Benachrichtigung in einem Cordova-Projekt Vanille zu implementieren.Implementieren Pusher APNs Benachrichtigung
Bis jetzt, ich bin in der Lage, Kommunikation mit dem Socket zu bekommen, wenn ich Daten von der Pusher-Konsole pushen, funktioniert alles, so dass ich jede Fehlkonfiguration auf Pusher API auszuschließen.
Die "einzige" Sache, die scheitern ist die tatsächliche Push-Benachrichtigung. Mit Blick auf die Push-Benachrichtigungskonsole sehe ich, dass meine Anfrage auf meinem Cordova-Kanal ankommt. Aber in der xCode Konsole, ich sehe nicht das erwartete Protokoll aus NSLog(@"Received remote notification: %@", userInfo);
Ich vermute, ich habe ein Problem mit meinem AppDelegate.m
was unten ist.
#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