首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >App42: ios设备上没有推送通知

App42: ios设备上没有推送通知
EN

Stack Overflow用户
提问于 2016-02-15 10:48:33
回答 1查看 488关注 0票数 0

上下文:

我正在尝试将cocos2d-x(v.3.8.1)应用程序从Parse迁移到App42。一切都很好,除了推送通知。

我所做的:

我遵循这个指南

使用-make App42兼容.p12证书的.p12->.pem->.p12转换

  • 将此证书上载到App42上,在服务器上以绿色突出显示。
  • 下载并安装用于Cocos2d-x的最新的App42 SDKVer.2.1
  • Appcontroller.mm中注册推送通知:
代码语言:javascript
复制
 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    …
        // Register for Push Notitications
        App42API::Initialize(APP42_KEY, APP42_SECRET);
        if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
                                                                                                 |UIRemoteNotificationTypeSound
                                                                                                 |UIRemoteNotificationTypeAlert) categories:nil];
            [application registerUserNotificationSettings:settings];
            [application registerForRemoteNotifications];
        } else {
            UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
            [application registerForRemoteNotificationTypes:myTypes];
        }
        …
}

 -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    NSString * deviceTokenString = [[[[deviceToken description]
                                      stringByReplacingOccurrencesOfString: @"<" withString: @""]
                                     stringByReplacingOccurrencesOfString: @">" withString: @""]
                                    stringByReplacingOccurrencesOfString: @" " withString: @""];
    app42->saveDeviceToken([deviceTokenString UTF8String]); // app42 is my singleton class for App42 methods
}

 -(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    [application registerForRemoteNotifications];
}

 -(void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
    NSLog(@"Failed to get token, error: %@", error);
}

-bind App42在我的单例App42Methods中使用APNS

代码语言:javascript
复制
void App42Methods::saveDeviceToken(string _deviceToken)
{
    int tag = TAG_DEVICE_TOKEN;
    deviceToken = _deviceToken;
    string userName = deviceToken.substr(0, 25);

    PushNotificationService::Initialize(APP42_KEY, APP42_SECRET);
    DeviceType deviceType = APP42_IOS;
    PushNotificationService* pushNotificationService = PushNotificationService::getInstance();
    pushNotificationService->RegisterDeviceToken(_deviceToken.c_str(), userName.c_str(), deviceType, app42callback(App42Methods::onPushRequestCompleted, this));
}

void App42Methods::onPushRequestCompleted(void *response)
{
    App42PushNotificationResponse *pushResponse = (App42PushNotificationResponse*)response;
    if (pushResponse->isSuccess)
    {
        log("Push notification service registered!");
    }
    else
    {
        printf("\nerrordetails:%s",pushResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",pushResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",pushResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",pushResponse->httpErrorCode);
    }
}

所以,注册程序是可以的。我在日志中获得"Push notification service registered!",在服务器App42 Cloud API -> Unified Notifications -> Push Users上可以看到创建的用户具有正确的设备令牌。

我在服务器上选择它并按他通知,此通知将显示为已发送。但我可以在我的设备上收到任何通知。

我想做的

我尝试将推送通知插件用于Cocos2d-x,结果是相同的。

我还使用APN,它记录«Failure performing handshake, error code -9806»

我也可以尝试App42 SDK用于iOS,但这将导致重写整个App42Methods类。我想避免这种情况。

推送通知在Parse.com上运行良好。

请告诉我我做错了什么?App42似乎没有连接到APNS,但我不知道为什么。

任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-16 06:18:08

握手问题通常是由于p12文件中的问题引起的。您也可以参考这个职位。我建议您按照相同的教程重新创建您的.p12文件,并尝试。如果您仍然面临这个问题,那么您可以在support@shephertz.com或App42社区论坛上进行快速解决。

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

https://stackoverflow.com/questions/35407350

复制
相关文章

相似问题

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