繁体   English   中英

在PushWoosh上Android设备的无效注册

[英]InvalidRegistration of Android Devices at PushWoosh

我正在使用以下PHP代码将推送通知发送到PushWoosh远程API。 它适用于iOS设备,并且似乎适用于Android设备(例如,我从API获得了所有适当的成功响应),但是只有在PushWoosh控制台和我的Android设备中收到InvalidRegistration报告时,Android的设备注册才出现问题已从PushWoosh注销。 有人阐明了为什么吗? 几乎不存在PushWoosh支持(在支付服务费用之前请考虑一下)。

我正在记录的响应消息与预期的一样-我取回了未知设备,注册了它们并收到每次注册的成功响应,然后我重新发送了通知,我取回的响应消息是成功的,并且没有显示未知的设备。 然后,我在PushWoosh控制台中检查推送历史记录,该报告显示InvalidRegistration消息,并且设备已删除。

<?php
//creates the notifications setting send time etc - this is not where the problem is
$notifications = $this->create_pushwoosh_notifications($devices);
$data = array("application"=>$appcode,
               "auth"=>$apptoken,
               "notifications"=>$notifications);

$pw = new push_woosh();
$r = $pw->create_message($data);
if($r){                         
 $response = json_decode($r[1]); 
 if($response->status_code != 200){
 //there was an error   
 }
error_log($response->status_message);
//retrieve message id's
$messages = $response->response->Messages;
//get any uknown devices associated with the message id's
$unknowns = $response->response->UnknownDevices;
//go through the messages
foreach($response->response->Messages as $message_id){
    //act if there is unknowns
    if(count($unknowns->$message_id)>0){//if there are unknown devices for a message
        //flag that we need to resend once we have finished registering unknown devices
        $resend = true;
           //change the devices in notifications to the unknowns for the message_id that contained unknown devices
            $notifications[$key[0]]['devices']=$unknowns->$message_id;
        //loop unknowns
        foreach($notifications[$key[0]]['devices'] as $device_id){
         $regdata = array(
                   "application"=>$this->appcode,
                    "push_token"=>$devices[$device_id]['user_tokenid'],
                    "language"=>"en",  // optional
                    "hwid"=> $devices[$device_id]['device_id'],//devices indexed by HWID
                    "timezone"=> 3600, // offset in seconds
                    "device_type"=>$devices[$device_id]['device_type'] 
                   );
    }
    //register the device
        $r = $pw->register($regdata);
         if($r){
                $response = json_decode($r[1]); 
                if($response->status_code != 200){
                    //there was an error
            }
            error_log($response->status_message);
            }else{
                //also an error
                }
    }else{//remove the notification as all devices were known and dont need to resend
        unset($notifications[$key[0]]);
        }
}
if($resend){//we need to resend
 //update $data with new $notifications
 $data['notifications']=$notifications;
 $r = $pw->create_message($data);
 if($r){
    $response = json_decode($r[1]); 
    if($response->status_code != 200){
        //there was an error
 }
 error_log($response->status_message);
 }else{
    //also an error
    }
 }
}else{
 //there was an error
 }

好,如果这对另一个人有用,我会很高兴的:

我们使用的是CakePHP静态字符串方法来生成设备ID

String::uuid();

它以以下格式输出字符串:

485fc381-e790-47a3-9794-1337c0a8fe68

在注册iOS设备时,PushWoosh对此没有任何问题,但是在将这种格式用于Android设备时,静默失败。 从中删除“-”,一切都很好。

Boo PushWoosh没有错误或回复我的电子邮件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM