Tutorial: How to Implement Push Notifications Using Google Cloud Messaging for Android — Part 1: Client App
This tutorial will walk you through how to successfully send push notifications to an application using Google Cloud Messaging (GCM).
Part 1—Client App covers the setup needed for a client application to register with GCM, send that registration information to the app server, and handle notifications it receives.
The parts in this process are:
- Create a Google Developer Project
- Enable API
- Add Credentials
- Create Android Project
- Get Google-Services Configuration (JSON) File
- Set Android Build Dependencies
- Android Manifest Modification
- Create Service Classes
- Fill in MainActivity.java Class
- Add in Strings
- Add in Colors
- Add in Layout
- Next Steps
Step 1: Create a Google Developer Project
Go to console.developers.google.com/project.
Click Create Project. Give the project a name. This name can NEVER be changed. However, it’s just an identifier for the back-end code. The Project ID you see is random, and it is also only used for back-end code identification. You don’t have to worry about trying to change it to a specific value—the one it randomly generates is fine.
Step 2: Enable API
You will then be taken to the main Google Developer’s Console page. You should see the name of your project in the header toward the right, so you know you’re in the correct place.
Under Mobile APIs, click on Google Cloud Messaging. (Sometimes there’s no Mobile APIs category and everything is listed together, in which case it’s called Google Cloud Messaging for Android.)
Click Enable.
You will then get a message saying that you can’t use the API until you’ve created credentials. That’s the next step.
Step 3: Add Credentials
Click the button Go to Credentials, which will take you to a page that looks like this:
(You can get to the same page by going to the API Manager sidebar on the left and clicking on Credentials).
Under Where will you be calling the API from?, choose your platform. E.g. To make an Android app, choose Android.
Click What Credentials Do I Need? to move on to part 2:
Name your API key. At this point, you can also make your API more secure by clicking Add Package Name and Fingerprint”. Don’t do this now though unless you know what you’re doing. Just click Create API Key.
It will now show you your API key. Copy and save it to a safe location.
Step 4: Create Android Project
Create a new project in Android Studio (or Eclipse if that’s your preference; all instructions will reference Android Studio though). Open its AndroidManifext.xml and copy its package name (e.g. com.example.myapp
) — you will need this for the next step.
Step 5: Get Google-Services Configuration (JSON) File
Make sure you’re signed into the same google account you used when you obtained your API key. Then go to the this link (part of the Google Developer’s Console) to obtain your Google Services JSON file.
You will see two fields. Click the drop-down for App Name and choose the corresponding project. Then in the space for Android Package Name, paste the package name of your Android project. Finally, click Continue to Choose and Configure Services.
If it’s not already selected, click Cloud Messaging.
Then click Enable Google Cloud Messaging to enable it. It will then show your your Server API Key (different than your project’s API key) and Server ID. Save both to the same safe location you stored your other number.
Scroll all the way to the bottom and click Continue to Generate Configuration Files.
Click Download google-services.json to get the JSON file.
Copy the google-services.json
to the app/ or mobile/ directory of your Android project (e.g. C:\User\MY_NAME\StudioProjects\MY_PROJECT_NAME\app
).
Step 6: Set Android Build Dependencies
Open your project in Android Studio (if it’s not already open) and go to the Gradle Scripts directory and open build.gradle (Project: YOUR_PROJECT_NAME).
Inside the dependencies block, include
classpath 'com.google.gms:google-services:1.5.0 classpath 'com.google.gms:google-services:2.0.0-alpha3'
(Only add if it’s not already there. Keep whichever version is most recent.)
From the same directory, open build.gradle (Module:app). At the top of the file, put:
apply plugin: 'com.google.gms.google-services'
Inside the dependencies block, put
compile 'com.google.android.gms:play-services-gcm:8.3.0'
Make sure the version number of play-services is the latest version. You find all versions (including the latest) in
android-sdks\extras\google\m2repository\com\google\android\gms\play-services
(usually within C:\Users\YOUR_NAME
.)
When you’re done, a pop-up should appear to let you sync your project with the gradle files.
Step 7: Android Manifest Modifications
Open your project’s AndroidManifest.xml file (located in Manifests).
Put the following permissions code between the <use-sdk> and <application> blocks:
<!-- Needs internet to connect to Google Services --> <uses-permission android:name="android.permission.INTERNET" /> <!-- Google Services requires a Google account --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps processor from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Permission to vibrate when receive a notification --> <uses-permission android:name="android.permission.VIBRATE" /> <!-- Lets app receive data messages. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Creates a custom permission using "signature" so that only this app can read the messages returned by GCM - YOUR_PACKAGE is your product's package name. E.g. com.example.test --> <permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />
Put the following code in the <application> block, after the <activity> sub-block. This is the code for your broadcast receiver, which handles the messages sent from GCM. The SEND permission is held by Google Play services. This prevents other apps from invoking the broadcast receiver.
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="YOUR_PACKAGE" /> </intent-filter> </receiver>
Directly below the receiver code, define the service(s) you will call. Pay attention to the “.” at the front of the name. This means you’re going to put the Java class for that service in the same folder as your MainActivity class (which is located in the folder called YOUR_PACKAGE in the java
folder).
<!-- Enables message handling (e.g.detecting different downstream message types, determining upstream send status, and automatically displaying simple notifications on the app’s behalf) --> <service android:name=".MyGCMListenerService" android:exported="false" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service> <!-- Handles the creation and updating of registration tokens --> <service android:name=".MyInstanceIDListenerService" android:exported="false" > <intent-filter> <action android:name="com.google.android.gms.iid.InstanceID" /> </intent-filter> </service> <!-- To get the registration token --> <service android:name=".RegistrationIntentService" android:exported="false" > </service>
Expected Error: You will likely notice an error if you hover over the service name that says Error: Cannot resolve symbol “YOUR_SERVICE_NAME”. This is because we haven’t created the corresponding Java classes yet. We will do that in the next step.
Step 8: Create Service Classes
Create the following classes in the java directory (the same directory as MainActivity.java). The code for these classes comes from the Google-Services Sample Code.
Note: You need to include your package name at the top of every class (this is not shown in the following code).
MyGCMListenerService
/** * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.NotificationCompat; import android.util.Log; import com.google.android.gms.gcm.GCMListenerService; public class MyGCMListenerService extends GcmListenerService { private static final String TAG = "MyGCMListenerService"; /** * Called when message is received. * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. } // [START_EXCLUDE] /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ sendNotification(message); // [END_EXCLUDE] } // [END receive_message] /** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received. */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) //.setSmallIcon(R.drawable.ic_stat_ic_notification) .setContentTitle("GCM Message") .setContentText(message) .setAutoCancel(true) .setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); } }
/** * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.content.Intent; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.util.Log; import com.google.android.gms.iid.InstanceID; import com.google.android.gms.iid.InstanceIDListenerService; public class MyInstanceIDListenerService extends InstanceIDListenerService { private static final String TAG = "MyInstanceIDLS"; /** * Called if InstanceID token is updated. This may occur if the security of * the previous token had been compromised. This call is initiated by the * InstanceID provider. */ // [START refresh_token] @Override public void onTokenRefresh() { // Fetch updated Instance ID token and notify our app's server of any changes (if applicable). Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } // [END refresh_token] }
/** * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class QuickstartPreferences { public static final String SENT_TOKEN_TO_SERVER = "sentTokenToServer"; public static final String REGISTRATION_COMPLETE = "registrationComplete"; }
/** * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.app.IntentService; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import com.google.android.gms.gcm.GcmPubSub; import com.google.android.gms.gcm.GoogleCloudMessaging; import com.google.android.gms.iid.InstanceID; import java.io.IOException; public class RegistrationIntentService extends IntentService { private static final String TAG = "RegIntentService"; private static final String[] TOPICS = {"global"}; public RegistrationIntentService() { super(TAG); } @Override protected void onHandleIntent(Intent intent) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); try { // [START register_for_gcm] // Initially this call goes out to the network to retrieve the token, subsequent calls // are local. // [START get_token] InstanceID instanceID = InstanceID.getInstance(this); String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); // [END get_token] Log.i(TAG, "GCM Registration Token: " + token); // TODO: Implement this method to send any registration to your app's servers. sendRegistrationToServer(token); // Subscribe to topic channels subscribeTopics(token); // You should store a boolean that indicates whether the generated token has been // sent to your server. If the boolean is false, send the token to your server, // otherwise your server should have already received the token. sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply(); // [END register_for_gcm] } catch (Exception e) { Log.d(TAG, "Failed to complete token refresh", e); // If an exception happens while fetching the new token or updating our registration data // on a third-party server, this ensures that we'll attempt the update at a later time. sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply(); } // Notify UI that registration has completed, so the progress indicator can be hidden. Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE); LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete); } /** * Persist registration to third-party servers. * * Modify this method to associate the user's GCM registration token with any server-side account * maintained by your application. * * @param token The new token. */ private void sendRegistrationToServer(String token) { // Add custom implementation, as needed. } /** * Subscribe to any GCM topics of interest, as defined by the TOPICS constant. * * @param token GCM token * @throws IOException if unable to reach the GCM PubSub service */ // [START subscribe_topics] private void subscribeTopics(String token) throws IOException { GcmPubSub pubSub = GcmPubSub.getInstance(this); for (String topic : TOPICS) { pubSub.subscribe(token, "/topics/" + topic, null); } } // [END subscribe_topics] }
Step 9: Fill in MainActivity.java Class
As before you will need to include your package name at the top of this class (this is not shown in the following code).
/** * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.content.LocalBroadcastManager; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.ProgressBar; import android.widget.TextView; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GoogleApiAvailability; public class MainActivity extends AppCompatActivity { private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; private static final String TAG = "MainActivity"; private BroadcastReceiver mRegistrationBroadcastReceiver; private ProgressBar mRegistrationProgressBar; private TextView mInformationTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences .getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { mInformationTextView.setText(getString(R.string.token_error_message)); } } }; mInformationTextView = (TextView) findViewById(R.id.informationTextView); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } } @Override protected void onResume() { super.onResume(); LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver, new IntentFilter(QuickstartPreferences.REGISTRATION_COMPLETE)); } @Override protected void onPause() { LocalBroadcastManager.getInstance(this).unregisterReceiver(mRegistrationBroadcastReceiver); super.onPause(); } /** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; } }
Step 10: Add in Strings
Copy the following code into the strings.xml file in the res directory in your program.
<resources> <string name="app_name">My Application</string> <string name="gcm_send_message">Token retrieved and sent to server! You can now use gcmsender to send downstream messages to this app.</string> <string name="registering_message">Generating InstanceID token...</string> <string name="token_error_message">An error occurred while either fetching the InstanceID token, sending the fetched token to the server or subscribing to the PubSub topic. Please try running the sample again.</string> </resources>
Step 11: Add in Colors
Create a colors.xml file in the res directory in your program and paste the following code.
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="blue_grey_500">#607D8B</color> <color name="blue_grey_600">#546E7A</color> <color name="blue_grey_700">#455A64</color> <color name="blue_grey_800">#37474F</color> <color name="blue_grey_900">#263238</color> </resources>
Step 12: Add in Layout
Here is the xml code for the layout of the app. It goes in activity_main.xml in the layout directory (located in the res directory of your program). Naturally, you can modify this layout as you desire—just be sure to update MainActivity.java to reflect any changes you make.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" android:background="@color/blue_grey_700" android:orientation="vertical" tools:context=".MainActivity"> <TextView android:text="@string/registering_message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/informationTextView" android:textAppearance="?android:attr/textAppearanceMedium" /> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/registrationProgressBar" /> </LinearLayout>
Step 13: Next Steps
In the next section of this tutorial, I will walk you through how to implement an app that will let you send push notifications to the client app you just created.
UPDATE 4-18-2016: Part 2 IS coming (I promise), I have just been super busy and haven’t had a chance to update this site with my tutorials. I hope to get to it by this upcoming weekend or the end of the month at the latest. Thanks for your patience!
A small typo: MyGCMListenerService and MyGcmListenerService.(Manifest link vs Classname)
Great tutorial by the way!
very well explained, when will be part2 available ?
Hi, Thanks for this nice article, it has all for android app.
Please share Part 2 🙂
Thanks,
Excellent but where is the implementation for part 2?
hi,
this post is very helpful for me,thank you for your valuable information. but am still stuck in to do the app server part.
so please help me to move the next level.
thank you.
I’m currently trying to figure out how to implement GCM into my App and your tutorial seems to be the only one around which adresses the new methods instead of the deprecated ones.
I hope you continue this tutorial soon!
Hey, it will be awesome if this is completed as soon as possible. This is one of the latest ones (after all those things changing) Many people are waiting for the latest tutorials preferably implementing topic messaging!!
Everything is changing after 2015 I/O and topic messaging is desperately needed!!
Thanks!
Thank you for this tutorial, it was quite helpful for a beginner. Looking forward to the next section!
Part 2 Please
Thanks for this wonderful post.
But where’s the next part? 😉
its very helpful tutorial for me..successfully got REG id for android device..
Thankyou..
where is the next tutorial for part 12?
Great Tutorial Mam… Helped me alot…
When will u publish next tutorial on GCM..
This is a very nice explanation of Gcm code. Liked it. Keep the good works..
It would be very helpful if u can send me the link for part 2 of this tutorial.
where is the next section of this tutorial? I followed the tutorial up to step 11 and now I am stuck in the mid way 🙁
Hi,
I don’t find the Part 2 … I would appreciate to read it.
Where is it?
Thanks in advance!
Hi Alberto, I have not had time yet to write Part 2. I hope to get it out in the next few weeks. Thanks for your patience!
Did you complete Part 2 for push notifications? I completed part 1 and I was looking for the next part.
Thank you,
Ed
great tutorial, great explanations!
Thanks a lot!
Hi, thanks for the awesome tutorial. I understand this better than the documentation I found from Google’s developer site. I’d like to know if you’ve been able to work on the next steps ie Step 12. I can’t seem to find the link.
Thanks.
Kindly upload next section tutorial
Lots of code i referred but this tutorial best ever … n now i want part 2 at server side n how it is implemented. Thank u mam.
Please reply me fast send me next tutorial..
where is the second part?
hey i am stuck i have refer all the links related gcm server and android side can you help me out to send on multiple devices push notifications. i will thankful ur lot
Nice….
Very Helpful !!!
Your tutorial really helped me! I’m trying to figure out where to find the 2nd part.
The tutorial is really helpful.. but it is only the half right now..
I have also written a post about sending push notification using gcm
please do check this as well
https://www.simplifiedcoding.net/android-push-notification-using-gcm-tutorial/
I really appreciate you for this very helpful tutorial. you saved my time and gift me and others programmers the best gift.
thanks so much.
I have complete the part 2 create the server side:
$registatoin_ids,
‘data’ => $message,
);
// Update your Google Cloud Messaging API Key
define(“GOOGLE_API_KEY”, “your_server_API_KeY”);
$headers = array(
‘Authorization: key=’ . GOOGLE_API_KEY,
‘Content-Type: application/json’
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
die(‘Curl failed: ‘ . curl_error($ch));
}
curl_close($ch);
return $result;
}
?>
$pushMessage,”x”=>”12″,”y”=>”33″);
$pushStatus = sendMessageThroughGCM($gcmRegIds, $message);
}
}
//Get Reg ID sent from Android App and store it in text file
if(!empty($_GET[“shareRegId”])) {
$gcmRegID = $_POST[“regId”];
file_put_contents(“GCMRegId.txt”,$gcmRegID);
echo “Done!”;
exit;
}
?>
Google Cloud Messaging (GCM) in PHP
div#formdiv, p#status{
text-align: center;
background-color: #FFFFCC;
border: 2px solid #FFCC00;
padding: 10px;
}
textarea{
border: 2px solid #FFCC00;
margin-bottom: 10px;
text-align: center;
padding: 10px;
font-size: 25px;
font-weight: bold;
}
input{
background-color: #FFCC00;
border: 5px solid #fff;
padding: 10px;
cursor: pointer;
color: #fff;
font-weight: bold;
}
$(function(){
$(“textarea”).val(“”);
});
function checkTextAreaLen(){
var msgLength = $.trim($(“textarea”).val()).length;
if(msgLength == 0){
alert(“Please enter message before hitting submit button”);
return false;
}else{
return true;
}
}
Google Cloud Messaging (GCM) in PHP
Oh your security cut the tags of the code
some thing deleted
what parts were deleted?
what parts of the code were deleted?
Can you update the part2 of this tutorial at the earliest??
Thnaks for this great code you provide,it is very helpful.
To achieve push notification in my android app..
Hi ArceJaeger, please say me that you have write the part 2?!