what is push notification in android apps development? how to implement this?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • impin
    New Member
    • Jul 2010
    • 127

    what is push notification in android apps development? how to implement this?

    i am new to android apps development. what is push notification in android apps development and how to implement this?
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Using push notifications basically means that the users device will somehow receive messages from a server which will result in a notification in the status bar - even if the app is not running itself. There are basically two ways of achieving this:
    1. Via SMS (text message). Here you will have to intercept the SMS and react to it in your app.
    2. Via a pulling service such as Google Cloud Messaging for Android. There are other similar services too (e.g. Urban Airship, PushWoosh, Deacon and Xtify) and they all have tutorials on their sites. So basically, decide which one you want to use and start with the tutorial to go with it.

    Comment

    • impin
      New Member
      • Jul 2010
      • 127

      #3
      can you give me any link with sample demo code. complete step by step demo... i tried Google Cloud Messaging for Android this but i get some error. GCM cannot reslove a type. not able to fix it.

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        There are step by step instructions on the Getting Started with GCM site. Did you follow all of those steps? If you can't resolve GCM to a type, you may not have installed the Google Cloud Messaging for Android Library in the SDK Manager (under Extras). Also make sure, that everything that sounds reasonable in that list is installed.

        Comment

        • impin
          New Member
          • Jul 2010
          • 127

          #5
          i have installed Google Cloud Messaging for Android Library and Google Play services. but still i'am getting that error.

          Code:
           public static final String EXTRA_MESSAGE = "message";
           public static final String PROPERTY_REG_ID = "registration_id";
           private static final String PROPERTY_APP_VERSION = "appVersion";
           private static final String PROPERTY_ON_SERVER_EXPIRATION_TIME =
                   "onServerExpirationTimeMs";
           public static final long REGISTRATION_EXPIRY_TIME_MS = 1000 * 3600 * 24 * 7;
           String SENDER_ID = "40824748037";
           static final String TAG = "GCMDemo";
           TextView mDisplay;
           GoogleCloudMessaging gcm;
           AtomicInteger msgId = new AtomicInteger();
           SharedPreferences prefs;
           Context context;
          getting error in this line
          Code:
          GoogleCloudMessaging gcm;
          Error: GoogleCloudMess aging cannot be resolved to a type

          Comment

          • Nepomuk
            Recognized Expert Specialist
            • Aug 2007
            • 3111

            #6
            Sounds like you haven't imported the class. Is there a line
            Code:
            import com.google.android.gms.gcm.GoogleCloudMessaging;
            at the top with the other imports? If not, add it.

            Comment

            • impin
              New Member
              • Jul 2010
              • 127

              #7
              okay.
              i added
              Code:
              import com.google.android.gms.gcm.GoogleCloudMessaging;
              this. but i get error
              Error: The import com.google cannot be resolved.

              screenshot:

              Comment

              • Nepomuk
                Recognized Expert Specialist
                • Aug 2007
                • 3111

                #8
                So, it doesn't know the library. You'll have to add the Google Play Services SDK library to your project as described here under the heading Set Up a Project with the Library. The library you're looking for should be in <android-sdk>/extras/google/google_play_ser vices/libproject/google-play-services_lib/ and is ideally copied into your projects classpath (as explained on the above website under Install the Google Play Services SDK, Point 4).

                Comment

                • Zaid Ahmed
                  New Member
                  • Jun 2013
                  • 1

                  #9
                  There are stepd of instructions on the Getting Started with GCM site. can you follow all of those steps? If you can't resolve GCM to a type, you may not have installed the Google Cloud Messaging for Android Library in the SDK Manager (under Extras). Also make sure, that everything that sounds reasonable in that list is installed.
                  there are also some other ways to do this job

                  Comment

                  • impin
                    New Member
                    • Jul 2010
                    • 127

                    #10
                    I am using eclipse.
                    i have installed Google Cloud Messaging for Android Library and Google Play services in SDK manager.


                    "If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it."

                    i don't get this. what i have to do?

                    Comment

                    • impin
                      New Member
                      • Jul 2010
                      • 127

                      #11
                      i imported the google play services. but still i have that error.
                      how to add that to the workspace?

                      Comment

                      • Nepomuk
                        Recognized Expert Specialist
                        • Aug 2007
                        • 3111

                        #12
                        In Eclipse, right click on the project you're working on (e.g. AndroidWebServi ces) and choose Properties. You want to modify the Java Build Path, so choose that. Then in the tab Projects add the lib project.

                        Comment

                        • rajatghai22
                          New Member
                          • Jan 2015
                          • 2

                          #13
                          Old method of implementing push notification is depriciated now. So you need ot implement it using latest method i.e using google play service library. Learn complete android gcm tutorial for here.
                          What do you need to do?
                          Create a IntentService, one broadcast receiver to listen to announcement that the notification has arrived. Also you need one main activity to process the received json object as a notification.

                          Comment

                          Working...