7

알림을 전송하지 않습니다PushSharp 내가 간단한 코드를 가지고있다

PushBroker pushBroker = new PushBroker(); 
string path = HttpContext.Current.Server.MapPath("~/" + AppSettings.CertificatePath); 
var appleCert = File.ReadAllBytes(path);   
pushBroker.RegisterAppleService(
      new ApplePushChannelSettings(AppSettings.IsProductionPushNotificationServer, 
             appleCert, 
             AppSettings.CertificatePassword)); 

var notification = new AppleNotification().ForDeviceToken(deviceToken.TrimStart('<').TrimEnd('>')) 
              .WithBadge(unviewedInvitationCount); 

pushBroker.QueueNotification(notification); 

나는 각각 샌드 박스와 개발 및 생산 sertificates 및 생산 서버를 사용하려고합니다. 그러나 아무 일도 일어나지 않습니다. 클라이언트 쪽에서 푸시 알림을받을 수 있습니다. 무엇이 잘못 되었나요? 미리 감사드립니다.

업데이트 : 나는 이벤트에 가입

.

OnNotificationFailed이 오류에 대해 나에게 말한다 :

{APNS NotificationFailureException -> 5 : Invalid token size -> {"aps":{"badge":1}}} 

내가 <에 내 장치 토큰을 포장하는 경우 ...> 나는 다른 오류가 나타납니다

{APNS NotificationFailureException -> 8 : Invalid token -> {"aps":{"badge":1}}} 

답변

19

귀하의 장치 토큰을하지 말았어야을 공백이 있으면 '<'또는 '>'문자를 입력하십시오. 64 자의 16 진수를 포함해야합니다. 그렇지 않으면 첫 번째 오류 (잘못된 토큰 크기)가 설명됩니다.

즉, 하지 <3948de8f 3948de8f ...>

3948de8f 3948de8f ...3948de8f3948de8f...

번째 오류 (유효하지 않은 토큰은) 아마 프로덕션 APNS 서버 또는 그 반대로 밀어 샌드 박스 장치 토큰을 사용하는 것을 의미한다. 샌드 박스 토큰은 샌드 박스 환경에서만 사용됩니다.

+0

감사합니다. – Neshta

+0

여러분을 환영합니다! – Eran

+0

그것은 나를 위해 일했다. "공백"이 나를위한 문제였습니다. – Raghav