0
이것은 서버에서 보내는 JSON 데이터 형식입니다.Android : Gcm이 JSON 형식을 변경합니까?
{
"s":1,
"es":true,
"event":{
"completed":0,
"pid":"13",
"eid":"8",
"event_start":"2015-03-09 05:30",
"event_end":"2015-03-09 06:30",
"event_type":"3",
"event_state":"1",
"followup_location":"hyderabad",
"notes":"test",
"person_met":"ANAND MS",
"id":"521",
"cid":null,
"rid":null,
"sid":null,
"actual_start":null,
"actual_end":null,
"followup_date":null,
"recording_path":null,
"predecessor_id":null
},
"gcm":" {\"multicast_id\":6761581515287135985,\"success\":1,\"failure\":0,\"canonical_ids\":0,\"results\":[{\"message_id\":\"0:1419657430616237%752516a3f9fd7ecd\"}]}",
"msg":{
"contacts":[
{
"id":"6",
"short_name":"AND",
"salutation":"Mr",
"first_name":"ANAND",
"last_name":"MS",
"sex":"M",
"dob":"2014-07-09",
"company_name":"SWAAS",
"company_address":"",
"designation":"",
"management_level":"",
"financial_capacity":"",
"status":null,
"email":null,
"door":null,
"block":null,
"flat_name":null,
"floor":null,
"street_name":null,
"locality_name":null,
"city":null,
"pincode":null,
"state":null,
"landmark":null,
"client_type":null,
"notes":null,
"lead_source1":null,
"lead_source2":null,
"lead_source3":null,
"lead_source_other":null,
"lead_source3_name":null
}
],
"project":{
"id":"13",
"name":"NewProject-AnandMS",
"short_name":"MS-Project",
"address":" Chennai 600041 ",
"requirements":null,
"status":"1",
"stage":"1",
"lat":null,
"lng":null,
"project_size":null,
"remarks":"",
"city":null,
"pincode":null,
"door":null,
"block":null,
"flat_name":null,
"floor":null,
"street_name":null,
"locality_name":null,
"state":null,
"landmark":null,
"project":null
}
},
"ids":[
"APA91bGllNaF9ESQrjJwux7GDDCEGw-L_6leIfOwLUVBpD0IsxvzIEFoRxA5KDLU4xTT7SwqBNz5fcVyHK492waOMJTE9F7JNOhlae6Y7_4UsUCOQb9BPSvBsA81GgvxURcPhkcczkDrITMiAhhHM1kQPm7GmAqgDg"
]
}
이는 본 JSON 데이터 포맷 I'am 수신하는 것이다.
[
{
project= {
"project_size":null,
"status":"1",
"street_name":null,
"state":null,
"locality_name":null,
"block":null,
"door":null,
"lng":null,
"remarks":"",
"short_name":"MS-Project",
"requirements":null,
"stage":"1",
"city":null,
"pincode":null,
"id":"13",
"project":null,
"landmark":null,
"floor":null,
"address":" Chennai 600041 ",
"name":"NewProject-AnandMS",
"flat_name":null,
"lat":null
},
from=467190216700,
event= {
"person_met":"ANAND MS",
"sid":null,
"predecessor_id":null,
"event_state":"1",
"followup_date":null,
"event_type":"3",
"recording_path":null,
"pid":"13",
"eid":"8",
"cid":null,
"id":"521",
"actual_end":null,
"rid":null,
"event_end":"2015-03-09 06:30",
"followup_location":"hyderabad",
"actual_start":null,
"notes":"test",
"event_start":"2015-03-09 05:30",
"completed":0
},
android.support.content.wakelockid=1,
collapse_key=do_not_collapse
}
]
이것은 Gcm 메시지에 작성한 코드입니다.
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// The getMessageType() intent parameter must be the intent you received
// in your BroadcastReceiver.
context = getApplicationContext();
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) { // has effect of unparcelling Bundle
/*
* Filter messages based on message type. Since it is likely that
* GCM will be extended in the future with new message types, just
* ignore any message types you're not interested in, or that you
* don't recognize.
*/
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
.equals(messageType)) {
sendNotification("Send error: " + extras.toString());
} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
.equals(messageType)) {
sendNotification("Deleted messages on server: "
+ extras.toString());
// If it's a regular GCM message, do some work.
} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
.equals(messageType)) {
System.out.println("gcmbundle"+extras.toString());
sendNotification("New Contact Received ");
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
}
}
내가 I'am이 project =
또는 JSON 형식으로 event =
을받는 이유를 모르겠어요. 일부 정보도 올바르게 수신되지 않았습니다. 읽고 도와 주셔서 감사합니다.
정확히 무엇을 묻고 싶습니까? – Rohit5k2
@ Rohit5k2 Gcm이 데이터를 받으면 JSON 형식이 변경됩니다. 네, 내 질문을 업데이트했습니다. – user3764346
이 json은 GCM이 아닌 서버에서 전송되어야합니다. 서버가 GCM으로 데이터를 보내 장치로 전달합니다. – Rohit5k2