Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 126.96.36.199 release ready!
Owner and Founder. Opencart
Android push notification is a service which notifies you that has any new data come or not in your smart device.
Android push notification is a service used by developers to send data to Android smartphones.
There are several different methods that can be used to implement Android push messages, the standard way is GCM (Google Cloud Messaging) but the alternatives are everywhere.
So here, We are using simply an alarmManager to make a request to the server after an interval and our custom API to make a response to android smartphones.
This is your primary activity named MainActivity.java, Here we have to set pendingIntent where pendingIntent is the instance of the Intent that starts the Activity when a user touches the push notification.
In above block of code,
alarmIntent – is an object of Intent.
PendingIntent – is the instance of the Intent that starts the Activity when a user touches the push notification.
AlarmManager – This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future.
PendingIntent.FLAG_UPDATE_CURRENT – Flag indicating that if the described PendingIntent already exists, then keep it but replace its extra data with what is in this new Intent. For use with getActivity, getBroadcast, and getService.
Here we have set the interval of 1000 * 60 * 60 * 2. Means It will run after every 2 hr.
In step 2, We are making a BroadcastReceiver class named AlarmReceiver.java.
Here, we send a request to the server and server send a response to the client (mobile device) and show to the form of push notification on smartphones.
In above code,
BroadcastReceiver – broadcast receiver who will intercept communication and notify us that something is working in our mobile. It is of 2 types:
NotificationCompat.Builder – Builder class for NotificationCompat objects. Allows easier control over all the flags, as well as help constructing the typical notification layouts.
An application listens for specific broadcast intents by registering a broadcast receiver in AndroidManifest.xml file.
Paste this xml code inside your <application> tag.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Very good company, we did get app extension for Magento 2 website. The support was very good they help us through the process. Webkul team is very supportive, I would recommend them.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.