Parse.com how to enable client pushes - parse-platform

I'm targeting specific users when sending Parse notifications, using their email address. The send seems to work okay, but no message is received. What do I need to change to receive the message?
In my Parse control panel it shows the attempted pushes but with the error message that "client-initiated pushes are not enabled". I really prefer initiating the pushes from the client. How do I enable that? I keep finding documentation that says to enable client pushes but I can't find how to do it.
Here is my setup:
Parse.initialize(this, "...xxxAPP_ID", "...xxxCLIENT_KEY");
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseObject parseObject = new ParseObject("defaultObject");
parseObject.put("email", sEmail)
parseObject.saveInBackground();
The actually sending is done here:
ParseQuery pQuery = ParseInstallation.getQuery();
pQuery.whereEqualTo("email", ToUser);
ParsePush parsePush = new ParsePush();
parsePush.setQuery(pQuery);
parsePush.sendMessageInBackground("You have pictures waiting from " + sEmail, pQuery);
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<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.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.pictureplay.permission.C2D_MESSAGE" />
<uses-permission android:name="com.pictureplay.permission.C2D_MESSAGE" />
<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>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.pictureplay" />
</intent-filter>
</receiver>
Update: I have narrowed the problem down to push notifications being received unless the service is not running. I thought the Parse service was supposed to load when the phone restarts, but this is not the case here. Is there a way to get the Parse service for my app to load when the phone reboots?
Update2:
The solution was to create a separate class (called "App" in my case) which initializes Parse. If the Parse service gets shut down when the app closes, the service restarts itself within minutes (automatically, I did no special setup for this) to be able to receive incoming push messages. These are the lines of code used in "App" onCreate:
Parse.enableLocalDatastore(this);
Parse.initialize(this, "data1", "data2"); //supply your own
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();

Have you enable Sending notifications from Client. Its a setting in Parse.com.
Go to settings ->App Permissions ->Allow client class creation. Set it to ON>

In your parse application Go to settings > Push > Client Push Enabled > set to Yes

The question Is there a way to get the Parse service for my app to load when the phone reboots? : Yes you can receive the BOOT_COMPLETE event if you have added the following permission on your manifest.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

In the new Parse DashBoard: go to settings---> push ---> push notification settings---> client enabled push --- >set to "yes"

Related

Unable to create an audience on Parse

I am trying to get my android app setup to send push notifications via Parse.
build.gradle
compile 'com.parse:parse-android:1.13.0'
Application.java
//in onCreate
Parse.initialize(this, "appId", "clientKey");
ParseInstallation.getCurrentInstallation().saveInBackground();
AndroidManifest.xml
<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>
<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>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="MY_APP_ID" />
</intent-filter>
</receiver>
After booting up my app with these changes, I can see an installation object being created on the Parse dashboard.
Now when I try to send a push via the dashboard and create an audience with platform Android, it says 'Your recipient count for this campaign can’t be empty.'
What am I missing?
EDIT 1: I am able to send a push via the REST api. Still not able to send push via the web console.
I had submitted this issue to the Facebook Developers page. This is the response that I received from the Facebook Engineering Team:
This is a known issue with small recipient counts in the new dashboard. Unfortunately the engineering team doesn't plan to solve this bug in the new dashboard. Please use the old dashboard to send these push notifications.

Jquery ajax doesn't work on phonegap app

I have been working on a phonegap app and it was working perfectly fine until today when the Ajax post request would get stuck loading and the success or failure callbacks are not being called but when I try it on the browser it works perfectly fine.
Has anyone came across this problem and if so how did you manage to fix it?
Thank you in advance
EDIT:
This is my first hybrid app and i am not using desktop app. for now I am only targeting iOS and the target version is 3 and I am using build
The newer version of the phonegap automatically blocks all the requests made to any server. You need to follow the instructions to make it work.
Add the "Cordova Whitelist Plugin" in your config.xml
<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />
Or simply
<plugin name="cordova-plugin-whitelist" spec="1.1.0" />
After that try putting the following in your config.xml
<content src="index.html" />
above mentioned is the path to your HTML file inside the source directory.
<access origin="*" />
will allow you to make request to any of the server using ajax. If you want to restrict your app to just a single domain then use something like this.
<access origin="http://yourdomain.com" />
At the end, put the following intents
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
For Android users who have this (I know that's not the original question):
I had the same problem, and spent a lot of time flailing unsuccessfully with the various whitelist directives as described above. Actually, my problem was different: my .apk file had not been correctly signed. Bizarrely, my Android phone did not kick it out at the point of trying to install the .apk: it simply failed as soon as I attempted to make an ajax call. I found the problem because Google Play refused to accept the upload.
I'm using Adobe PhoneGap Build to create the .apk: the problem was fixed when I added my Android keystore to the build (and disabled debug, which I don't think was relevant, but I'm not sure).
its work for me :
in path platforms/android update file AndroidManifest.xml :
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

Sending pushes to devices without google play account

We're developping an Android app which uses Parse. All devices that install the app have their deviceToken and pushType registered in _Installation Parse Table upon registration, since they have google play accounts. They all receive push notifications from Parse without any problems.
I have a fairphone device which has been used for testing purposes since the beginning. It has never had google play account, but Parse push notifications were succesfully received without problems. But some three months ago, this device doesn't get push notifications anymore. I have uninstalled the app completely, erased all data, given again permission to receive notifications, but nothing works.
I can't understand why this device doesn't get push notifications from Parse.
My question is: is there a way to debug my app and discover why a certain device doesn't get parse push notifications?
This is my manifest part related to parse push notifications:
<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>
<receiver android:name="br.org.eita.responsa.push.ResponsaPushReceiver"
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>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="br.org.eita.responsa" />
</intent-filter>
</receiver>

Parse - Installation table not setting deviceToken nor pushType

I had an app working on Parse, with the notifications working fine. I changed app packaging and I create a new app on Parse.
With the new app, deviceToken and pushType columns remain always empty on table _Installation, so pushes doesn't work even if sent from Parse web page, and a new entry is generated as application is launched.
I've updated parse keys on my java code and on my cloud code.
Someone has some idea what I may have missed or what may happen so the same code has different behaviour in different apps with equivalent configurations?
If I update one of the installation with pushType="gcm" and "deviceToken" the one I had in the other app, this device receives notifications.
Thank you
okay, I had a similar issue. both those columns were empty.
this is mainly due to the manifest issue.
your permissions seem okay because you are getting the notification and also able to reg in the parse data base.
so the problem should be in the <receiver> tags there should only be 2 of them like mine.
<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.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: If you change the package name of this sample app,
change "com.parse.tutorials.pushnotifications" in the lines
below to match the new package name.
-->
<category android:name="com.example.ifis" />
</intent-filter>
</receiver>
if you have any receiver like "com.google.android.gcm.GCMBroadcastReceiver" pls remove and also one <service android:name="com.parse.PushService" />
Enable parse logging:
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
In my case I was missing GCM permissions
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="my.package.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="my.package.permission.C2D_MESSAGE" />

Rhomobile: Custom URL Schemes

I'm writing a Rhomobile application targeted at iPhone and Android.
I need to create a custom url scheme, so that i can create urls that look like test://some-params that will launch my program and will pass it the params.
As far as I understand this is done in build.yml through the BundleURLScheme parameter, and then System.get_start_params() to get those parameters.
However, this works on the iPhone only as far as I understand.
Is there any way to make this work on Android too?
Thanks alot!
OKay, I've found the answer myself, in case anybody needs this too:
Create an extension to the application as explained here:
http://docs.rhomobile.com/rhodes/extensions#generating-a-native-extension-template
Add an android_manifest_changes file, as decribed in the above link.
In that file add the following lines:
<manifest xmlns:android='http://schemas.android.com/apk/res/android'
android:versionName='1.0' package='com.rhomobile.webbrowserpoc'
android:versionCode='10000' android:installLocation='auto'>
<application android:name='com.rhomobile.rhodes.RhodesApplication'
android:label='#string/app_name' android:icon='#drawable/icon'
android:debuggable='true'>
<activity android:name='com.rhomobile.rhodes.RhodesActivity'
android:label='#string/app_name' android:launchMode='singleTask'
android:configChanges='orientation|keyboardHidden'
android:screenOrientation='unspecified'>
<intent-filter>
<action android:name='android.intent.action.VIEW' />
<category android:name='android.intent.category.BROWSABLE' />
<category android:name='android.intent.category.DEFAULT' />
<data android:pathPrefix='' android:scheme=''
android:host='' />
</intent-filter>
</activity>
</application>
Only the <data android:pathPrefix='' android:scheme='' android:host='' /> line should be filled in with correct properties.

Resources