Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse Push notifications on Android

I am making an app that will use the Parse.com Push notifications, however it is not working like the guide shows.

The issue is, i have set up the Parse push activity fine, registered the new installation, and am able to see which channels a user is subscribed to. I am able to receive the Push notification from parse, but unable to send from my app.

There are no errors following in logcat, and parse records that a push was sent, but shows that there are "no subscribers" to the channel.

In my onCreate:

Parse.initialize(MainActivity.this, "***", "***");
    PushService.setDefaultPushCallback(this, MainActivity.class);
    PushService.subscribe(this, "Everyone", MainActivity.class);
    ParseInstallation.getCurrentInstallation().saveInBackground();

The Push code:

ParsePush push = new ParsePush();
    push.setChannel("Everyone");        
    push.setMessage("Hey!");
    push.sendInBackground();

The manifest:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> 

<application>
   ....

<service android:name="com.parse.PushService" />
    <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>
</application>

There are no errors in logcat, everything seems to be sent smoothly, but in parse i get the following messages:

My Push

You sent this push notification to 0 recipients.

Targeting : channels includes "Everyone"
Sending date : November 28th, 2013 at 9:40 AM
Expiration : None
Full target : { "channels": { "$in": [ "Everyone" ] } }
Full data : {"alert"=>"Hey!"}

The only changes i can see from the push that i send vs the Push that parse.com sends is the "Full data" field

Parse Push

Targeting : channels includes "Everyone"
deviceType is "android"
Sending date : November 28th, 2013 at 9:21 AM
Expiration : None
Full target : { "channels": { "$in": [ "Everyone" ] }, "deviceType": "android" }
**Full data : { "alert": "hi" }**

Thanks in advance for any help / ideas

like image 215
ViperJuice2012 Avatar asked Nov 28 '13 17:11

ViperJuice2012


People also ask

How do I see push notifications on Android?

Turn on notifications for Android devicesTap More on the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Show notifications.

Can push notifications be intercepted?

Push notifications, when implemented properly, are resistant to interception or redirection and are, therefore, more secure than SMS.


2 Answers

You should turn on push notification from parse setting on the website parse.com

App -> Settings -> Push Notifications -> Client push enabled (should be on)

like image 68
bahakz Avatar answered Nov 15 '22 20:11

bahakz


In my case, I defined a packageName in the AndroidManifest.xml different of the build.gradle... it took 3 hours to realize the error. Maybe it could help :)

like image 32
Rafael Ruiz Muñoz Avatar answered Nov 15 '22 21:11

Rafael Ruiz Muñoz