简体   繁体   中英

Android GCM Push notification not giving any notifications

Hello all I am trying to implement Push Notification Using GCM. I am using This Link . I am using API 15

<uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />




static final String SERVER_URL = "http://10.0.2.2/gcm_server_php/register.php"; 

    // Google project id
    static final String SENDER_ID = "2*********12"; //12 digit ID

I have give this permission to Manifest.xml

<permission
        android:name="com.example.googlecoludmessaging.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.googlecoludmessaging.permission.C2D_MESSAGE" />

    <!-- This app has permission to register and receive data message. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <!-- Network State Permissions to detect Internet status -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

But this not giving me any Display or any notifications. I have tried in emulator as well as in device

Thanks in advance.

i think this tutorial uses old api.

visit https://developer.android.com/google/gcm/index.html

GCM not Working (its my Qustion, there is no error in Program)

Try to follow the official guide step by step: https://developer.android.com/google/gcm/gs.html

What you need to do is to implement a server (to send notifications which you can do anywhere -- in the link you referred to, it's done on a PHP server but it can be any server/machine that can send JSON format HTTP POST) and a client side implementation to react to these notifications. You need to implement the correct sets of services and intents in your client to react to them. To implement your client, read this: https://developer.android.com/google/gcm/client.html . To implement your server: https://developer.android.com/google/gcm/server.html

If you're sending notifications from your server, check that you don't receive any exceptions when you connect to GCM (ie you keys are all in order, your request is of the correct format and the HTTP POST is successful) and then attempt to put breakpoints in your GCM service/broadcast intent to see if you receive anything. If you follow the official guide, you should be able to get this working easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM