2014-07-22 6 views
0

에 대해 제공된 알림 페이로드가 유효하지 않습니다. 따라서 Xamarin.Android http://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-mobile-services-android-get-started-push/에 대한 푸시 알림 샘플을 실행하고 문서의 지침에 따라 실행 해 보았습니다. 항목의 삽입은 절대적으로 잘 작동하지만 푸시 알림은 작동을 거부합니다.azure 로그 표시 : 공식 Xamarin.Android 샘플

이것은 Azure 푸시에 대한 오류입니다. 오류 : 400 - 제공된 알림 페이로드가 유효하지 않습니다.

다른 사용자가 기기에서이 샘플을 실행 해보고 푸시 알림을 시도 했습니까? 이 오류는 내 사건을 돕는 데별로 도움이되지 못합니다.

샘플에 PushSharp가 사용됩니다.

어떤 도움을 주셔서 감사합니다. 무리 감사!

답변

0

이렇게하면 Google 클라우드 메시징에 백엔드 서버에서 푸시 알림을 보내는 방법입니다. - 내가 위의 링크 된 샘플을 참조

protected override void OnMessage(Context context, Intent intent) 
{ 
    var message = intent.Extras.GetString("message"); 

    // message is JSON payload 
    // { "id":"someid", "index":"1", "text":"some text","from"... } 

    var json = JObject.Parse(message); 
    var id = json["id"].ToString(); 
    var index = json["index"].ToString(); 
    var text = json["text"].ToString(); 
    var from = json["from"].ToString(); 
    var when = DateTime.Parse(json["when"].ToString()); 

    // do whatever you want with your values here 

} 
+0

이봐, 백엔드는 푸른 :

public async Task<bool> SendNotification(int id, int index, string from, string text, string tag) { try { var payload = new { data = new { message = new { // this part can be anything you want id, index, from, text, when = DateTime.UtcNow.ToString("s") + "Z" } } }; var json = JsonConvert.SerializeObject(payload); await _hubClient.SendGcmNativeNotificationAsync(json, tag); return true; } catch (ArgumentException ex) { // This is expected when an APNS registration doesn't exist. return false; } 

다음 앱 의도 서비스에, 당신은 JSON "메시지"를 구문 분석 할 수 있습니다. 나는 이것을 해결하고 푸시 알림 성공 로그를 얻지 만 OnMessage 메서드는 호출되지 않습니다. 어떤 아이디어? –

+0

시작시 장치를 등록하셨습니까? – Kiliman

+0

그래, 로그 장치가 등록되어 보여줍니다. 서버는 푸시가 전송되었다고 말했지만 Onmessage()는 호출되지 않습니다. –