0

i am using parse 1.13.0 in nodechef.com i tried setting my app to send notification but i getting some problems.

This is my Manifest:

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.path" >
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.my.path.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.my.path.permission.C2D_MESSAGE" />

<application
    android:name=".MainApplication"
    android:allowBackup="true"
    android:fullBackupContent="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:theme="@style/hsfTheme">

    <meta-data
        android:name="com.parse.APPLICATION_ID"
        android:value="@string/parse_app_id" />
    <meta-data
        android:name="com.parse.CLIENT_KEY"
        android:value="@string/parse_client_key" />

    <meta-data
        android:name="com.parse.push.notification_icon"
        android:resource="@drawable/logo" />

    <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.my.path" />
        </intent-filter>
    </receiver>

    <!-- activity main. -->
    <activity
        android:name=".A0"
        android:configChanges="keyboardHidden|screenLayout|orientation"
        android:immersive="true"
        android:screenOrientation="portrait"
        android:theme="@style/hsfTheme.NoActionBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".A1" />
    <activity android:name=".A2" />
    <activity android:name=".A3" />
    <activity android:name=".utils.A4" />

    <!-- Include the AdActivity configChanges and theme. -->
    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />
</application>

in my application class i have: ParseInstallation.getCurrentInstallation().saveInBackground();

  • DeviceToken is empty in _Installation class
  • Push not working

All i need is send push notification from my app, in some actions i would like notify all users or some users using Installation channels. Don't care if i will use "parse push" or gcm, just need a simple way to send push notifications from app.

EDIT Push from parse-dashboard is working now, but i cant send push notification from client. I tried a push and got "unauthorized: enable master key". So what i need to do ?

EDIT 2 I created a cloud code but its looks not working get values from request.params:

Parse.Cloud.define("sendPush", function(request,response) {
var _locale = "en-US";//request.params.locale;
var _message = "test";//request.params.message;
var query = new Parse.Query(Parse.Installation);
query.equalTo("localeIdentifier", _locale);
Parse.Push.send({
        data:   {
            alert: _message,
        badge: "Increment",
            sound: "default"
        },
        where: query
    }, {
      useMasterKey: true
    })
    .then(function() {
      response.success("Push Sent!");
    }, function(error) {
      response.error("Error while trying to send push " + error.message);
    });
});

EDIT 3

HashMap<String,String> map = new HashMap<String, String>();
map.put("locale","en-US");
map.put("message","Text added");

ParseCloud.callFunctionInBackground("sendPush",map, new FunctionCallback<Object>() {

    @Override
    public void done(Object object, ParseException e) {
        // toast done
    }
});
18
  • 1
    what is the problem? can you please share more code? Commented Aug 2, 2016 at 3:45
  • @RanHassid i added more information about the problem. Commented Aug 2, 2016 at 11:26
  • you use parse.com or parse-server? Commented Aug 2, 2016 at 13:58
  • i use nodechef.com with parse-server Commented Aug 2, 2016 at 17:48
  • 1
    and did you follow this guide here: github.com/ParsePlatform/parse-server/wiki/Push Commented Aug 2, 2016 at 17:51

1 Answer 1

1

after investigate it a bit i noticed that in order to send push you must create cloud code function and use your master key (by sending userMasterKey=true parameter to the send push function. I describe my answer in here so please go through the steps and it should work for you.

Sign up to request clarification or add additional context in comments.

5 Comments

Tks Ran, i found CLI tool. But i would like to know how to deploy your script (i never did it before and i am worried about crash default settings).
When you deploy parse-server it also deploy your cloud code script. the cloud code script should be located under the cloud folder there you can create all the cloud code functions
So i will need get all my code before deploy, right ? well, i need read about node js to learn hot to deploy, download source, etc...
In parse-server docs you can find how to deploy parse-server to different cloud providers such as: AWS, google cloud, heroku and more. go to this link: github.com/ParsePlatform/parse-server and read the instructions under "Running Parse Server elsewhere"
Ran, i edited question again, can you check and try help me again ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.