2014-11-03 3 views
0

php에서이 기능을 사용하면 App A 및 App B에 2 개의 알림을 전송합니다. 그러나 하나의 APP에서만 1 개의 알림 만받습니다. apnsphp를 사용하여 알림을 푸시합니다.php apns push를 사용하여 기기에서 모든 알림을받을 수 없음.

다음은 내 상황입니다. 2 개의 앱이 있습니다. 앱 A와 앱 B 두 앱 모두 서로 다른 apns 인증서를 사용하고 있습니다.

apns cert 캐시가있을 수 있습니까? APP A의 IPAD에 로그인하면 시나리오 1) & 동시에 APP B와 IPAD에 로그인

통지 푸시는 B.

시나리오 2) APP A의되지 앱 수신 APP A를 사용하여 IPAD에 로그인하고 APP B를 사용하여 iPhone (별도 장치)에 로그인하면 APP A가 아닌 APP A에 대한 푸시 알림이 수신됩니다.

시나리오 3) APP A로 iPad에서 로그 아웃 한 경우 시나리오 3) , APP B를 사용하여 iPad (동일한 장치) 또는 iPhone (별도 장치)에 로그인하면 푸시 알림이 수신됩니다. App B.

임 apnsphp에서이 오류가 : 아래

["ERRORS"]=> array(2) { 
[0]=> 
array(3) { 
["identifier"]=> int(1) 
["statusCode"]=> int(999) 
["statusMessage"]=> string(53) "Internal error (0 bytes written instead of 223 bytes)" 
} 
[1]=> 
array(5) { 
["command"]=> int(8) 
["statusCode"]=> int(8) 
["identifier"]=> int(1) 
["time"]=> int(1415012295) 
["statusMessage"]=> string(13) "Invalid token" 
} 
} 

는 로그입니다

Tue, 04 Nov 2014 10:02:25 +0800 ApnsPHP[4136]: INFO: Trying tls://gateway.push.apple.com:2195... 
Tue, 04 Nov 2014 10:02:26 +0800 ApnsPHP[4136]: INFO: Connected to 
tls://gateway.push.apple.com:2195. Tue, 04 Nov 2014 10:02:26 +0800 ApnsPHP[4136]: INFO: Sending 
messages queue, run #1: 1 message(s) left in queue. Tue, 04 Nov 2014 10:02:26 +0800 
ApnsPHP[4136]: STATUS: Sending message ID 1 [custom identifier: CakeApns] (1/3): 166 bytes. Tue, 
04 Nov 2014 10:02:27 +0800 ApnsPHP[4136]: INFO: Disconnected. 

Tue, 04 Nov 2014 10:02:27 +0800 ApnsPHP[4136]: INFO: Sending messages queue, run #1: 1 message(s) 
left in queue. Tue, 04 Nov 2014 
10:02:27 +0800 ApnsPHP[4136]: STATUS: Sending message ID 1 [custom identifier: CakeApns] (1/3): 
221 bytes. Tue, 04 Nov 2014 10:02:27 +0800 ApnsPHP[4136]: ERROR: Unable to send message ID 1: 
Internal error (0 bytes written instead of 221 bytes) (999). Tue, 04 Nov 2014 10:02:27 +0800 
ApnsPHP[4136]: INFO: Trying tls://gateway.push.apple.com:2195... Tue, 04 Nov 2014 10:02:28 +0800 
ApnsPHP[4136]: INFO: Connected to tls://gateway.push.apple.com:2195. Tue, 04 Nov 2014 10:02:28 
+0800 ApnsPHP[4136]: INFO: Sending messages queue, run #2: 1 message(s) left in queue. Tue, 04 
Nov 2014 10:02:28 +0800 ApnsPHP[4136]: STATUS: Sending message ID 1 [custom identifier: CakeApns] 
(2/3): 221 bytes. Tue, 04 Nov 2014 10:02:28 +0800 ApnsPHP[4136]: ERROR: Unable to send message ID 
1: Invalid token (8). Tue, 04 Nov 2014 10:02:28 +0800 ApnsPHP[4136]: INFO: Disconnected. Tue, 04 
Nov 2014 10:02:28 +0800 ApnsPHP[4136]: INFO: Trying tls://gateway.push.apple.com:2195... Tue, 04 
Nov 2014 10:02:29 +0800 ApnsPHP[4136]: INFO: Connected to tls://gateway.push.apple.com:2195. Tue, 
04 Nov 2014 10:02:29 +0800 ApnsPHP[4136]: INFO: Sending messages queue, run #3: 1 message(s) left 
in queue. Tue, 04 Nov 2014 10:02:29 +0800 ApnsPHP[4136]: WARNING: Message ID 1 [custom 
identifier: CakeApns] has an unrecoverable error (8), removing from queue without retrying... 
Tue, 04 Nov 2014 10:02:30 +0800 ApnsPHP[4136]: INFO: Disconnected. 

답변

0

내가 ApnsComponent 파일을 편집하여 그것을 해결.

새로운 공용 변수에 추가했습니다 : previousData 이 변수는 연결되어있는 현재의 combined_cert_path를 저장합니다. 내 인증서 경로를 전환 할 때 인증서 경로가 연결된 인증서 경로와 동일한 지 확인합니다. 그것이 같지 않으면, 나는 apns에 다시 연결할 것입니다. 그것이 같은 경로라면, 나는 사실로 돌아갈 것이다.

확인은 서버가 다시 연결되는 것을 방지하고 전송 시간을 늘리는 것입니다.

private function __connect() { 
    if($this->previousData == ""){ 
      $this->previousData = $this->combined_cert_path; 
      $this->__push = new ApnsPHP_Push($this->env, $this->combined_cert_path); 
      $this->__push->setProviderCertificatePassphrase($this->cert_passphrase); 

      $logger = new ApnsPHP_Log_Custom(!$this->__logEnabled); 
      $this->__push->setLogger($logger); 
      //$this->__push->setSendRetryTimes($this->__sendRetryTimes); 
      $this->__push->connect(); 
      return $this->__logError(); 
    } 
    else if($this->previousData != $this->combined_cert_path){ 

      $this->previousData = $this->combined_cert_path; 
      $this->__push = new ApnsPHP_Push($this->env, $this->combined_cert_path); 
      $this->__push->setProviderCertificatePassphrase($this->cert_passphrase); 

      $logger = new ApnsPHP_Log_Custom(!$this->__logEnabled); 
      $this->__push->setLogger($logger); 
      //$this->__push->setSendRetryTimes($this->__sendRetryTimes); 
      $this->__push->connect(); 
      return $this->__logError(); 
    }else{ 
     return true; 
    } 
}