上下文:
我正在尝试将cocos2d-x(v.3.8.1)应用程序从Parse迁移到App42。一切都很好,除了推送通知。
我所做的:
我遵循这个指南:
使用-make App42兼容.p12证书的.p12->.pem->.p12转换
Appcontroller.mm中注册推送通知: -(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
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,但我不知道为什么。
任何帮助都将不胜感激。
发布于 2016-02-16 06:18:08
握手问题通常是由于p12文件中的问题引起的。您也可以参考这个职位。我建议您按照相同的教程重新创建您的.p12文件,并尝试。如果您仍然面临这个问题,那么您可以在support@shephertz.com或App42社区论坛上进行快速解决。
https://stackoverflow.com/questions/35407350
复制相似问题