首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >实施Pusher APNs通知

实施Pusher APNs通知
EN

Stack Overflow用户
提问于 2017-01-06 05:18:02
回答 1查看 204关注 0票数 0

遵循来自nickjf89的这个promising tutorial,我尝试在一个普通的Cordova项目中实现推送通知。

到目前为止,当我从Pusher控制台推送数据时,我能够与套接字进行通信,一切正常,所以我排除了Pusher API上的任何错误配置。

“唯一”失败的是实际的推送通知。查看推送通知控制台,我看到我的请求到达我的cordova频道。但是在xCode控制台中,我没有看到来自NSLog(@"Received remote notification: %@", userInfo);的预期日志

我怀疑我的AppDelegate.m有问题,如下所示。

代码语言:javascript
复制
#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
EN

回答 1

Stack Overflow用户

发布于 2017-01-06 06:25:15

好了,再说一次,问题出在椅子和键盘之间……我找到了修复程序,它与上传到Pusher和my-app-name.entitlements上的APNs证书有关,其中APS环境被设置为生产而不是开发。

所有的修复和功能,伟大的新功能从推手!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41494857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档