How to send images and website link through GCM..?

时光毁灭记忆、已成空白 提交于 2019-12-06 13:59:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!