问题
I am sending messages through GCM but i can't find a method to send images and website link through GCM messages...to devices so that if we tap on notification then web link should be opened or image must be downloaded or shown..?
回答1:
You can send the weblinks in GCM Message
In Client ( GCMIntentService ) -
@Override
protected void onMessage(Context context, Intent intent) {
String uriStr = intent.getStringExtra(FIELD_MESSAGE);
//FIELD_MESSAGE is the same key used while sending links from server
Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriStr));
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(970970, notification);
}
回答2:
I wrote two blog posts that describes two methods for doing this: Tutorial: Using AirBop to Send Images in the Message Payload and Tutorial: Using AirBop to Push Images for BigPictureStyle Notifications the posts use AirBop as their application server, but you can use the same idea with whichever server you are using with GCM.
回答3:
I will approach like this 1)Send GCM notification to client along with URL 2)Based on URL received, download the image 3)once downloaded, save the image and set the notification
来源:https://stackoverflow.com/questions/14392820/how-to-send-images-and-website-link-through-gcm