푸시 구현중인데요..
보내는쪽이 잘못된 것일까요? 받는쪽이 잘못된 것일가요?
private void showMessage(Context context, Intent intent){
String title = intent.getExtras().getString("title");
String contents = intent.getExtras().getString("contents");
NotificationManager mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class), 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(title))
.setContentText(contents);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(0, mBuilder.build());
mBuilder.setAutoCancel(false);
}
보내는쪽(서버)
닷넷으로 구현되었습니다.
private string SendGCMNotification(string apiKey, string postData, string postDataContentType)
{
ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateServerCertificate);
// MESSAGE CONTENT
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// CREATE REQUEST
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://android.googleapis.com/gcm/send");
Request.Method = "POST";
Request.KeepAlive = false;
Request.ContentType = postDataContentType;
Request.Headers.Add(string.Format("Authorization: key={0}", apiKey));
Request.ContentLength = byteArray.Length;
Stream dataStream = Request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
// SEND MESSAGE
try
{
WebResponse Response = Request.GetResponse();
HttpStatusCode ResponseCode = ((HttpWebResponse)Response).StatusCode;
if (ResponseCode.Equals(HttpStatusCode.Unauthorized) || ResponseCode.Equals(HttpStatusCode.Forbidden))
{
var text = "Unauthorized - need new token";
Console.Write(text);
}
else if (!ResponseCode.Equals(HttpStatusCode.OK))
{
var text = "Response from web service isn't OK";
Console.Write(text);
}
StreamReader Reader = new StreamReader(Response.GetResponseStream());
string responseLine = Reader.ReadToEnd();
Reader.Close();
return responseLine;
}
catch (Exception e)
{
}
return "Error";
}
아니면 targetSdkVersion="19" 버전문제인지?
푸시알람 클릭후 삭제도 안되고..................
여러가지 문제인데...고수님들 조언 부탁드립니다.
코드상의 문제는 없는듯 한대...뭐가 잘못된것 일까요?
감사합니다.