1

I am new to android, I am making an app which is installed by n users. When they add a new record in the database I would like to notify all users who has installed the app with,"[user] added a new comment [data]". I tried to use parse sdk,like onCreate I added,

public void onCreate() {
  Parse.initialize(this, "aaaa", "bbbb");
  ParseInstallation.getCurrentInstallation().saveInBackground();
}

Also I changed the xml file and added,

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>
    <receiver
        android:name="com.parse.ParsePushBroadcastReceiver"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>

and some other as stated in the website. But I have to manually go to the parse website and "create push" and send to all. But I want to make it automatic. Like whenever a new message is inserted, push it. How can I achieve it programmatically.

rici
  • 234,347
  • 28
  • 237
  • 341
Hunterr
  • 553
  • 1
  • 8
  • 28
  • 1
    write a server code for sending notification.....manage device id at server side .... whenevr user enter new entry call server send method which will send and notify all users ... – koutuk Sep 07 '15 at 06:36
  • can I use php to send the push notification as I am handling database using php? – Hunterr Sep 07 '15 at 06:44
  • 1
    http://stackoverflow.com/questions/25859898/sending-push-notifications-to-multiple-android-devices-using-gcm – koutuk Sep 07 '15 at 06:50
  • Thanks for the help, I will give it a try and let you know if I face any difficulties. Thanks again :) – Hunterr Sep 07 '15 at 06:52
  • One more thing, do I need to call the php file when the data is stored in database or maintain a separate AsyncTask for it? – Hunterr Sep 07 '15 at 06:59
  • Yes... you need to invoke php server method each time .. – koutuk Sep 07 '15 at 07:00
  • great ! i will give it a hit. :) – Hunterr Sep 07 '15 at 07:01
  • @koutuk : Can you help me with CustomReceiver Class or have a look at http://stackoverflow.com/questions/34052646 – Hunterr Dec 03 '15 at 10:09

0 Answers0