Update follow this post to send push notification using firebase


In this post i am going to explain how to send image in your push notification. Image notification is very useful to promote your product or if you are building app for e-commerce to attract more customer to your online store. So here is simple code for push notification with image which help to build notification and service like that.

Send image push notification google GCM - trinitytuts


To test demo please download sample .apk file from above download link

Server side code for GCM:

Create new php file in your server directory where we save user id and also send push notification to user. Copy below code and paste in your file, here i create a .txt where i save user GCM ID and also send image after upload. Before we go further please make sure your server directory have read write permission because i am creating a txt file from where i read GCM id to send notification.


Above code help you create .txt file and save text in that file.


Above code load registration id from your text file and also upload image and send it to your device. Note: please upload small size image so that image load easily. Also enter your server key above.

Android code

Step 1. Create new android project in android studio.

Step 2. Open project AndroidManifest.xml file and add some require permission, receiver and Google Api key in it.

Step 3. Open your activity_main.xml file inside res ⇒ layout and copy paste below code here i create two button first button help to register your app with google server and get GCM ID, and second button pull that GCM ID to server.

Step 4. Now open your MainActivity.java file add below code in it here we register user with Google GCM server.

Step 5. Now create receiver

Step 6. Now create new new java class and name it GCMNotificationIntentService.java this class show notification and also load image from server and show it in notification bar.

this method show notification with image and also read image URL from json string

Below method load image from URL we get from GCM and convert it to bitmap.

For complete code please follow above download link. Hope this will help you.