问题
I recently set up local parse server on my machine following the github instructions on PARSE SERVER EXAMPLE repo. My server is up and running i have included the Parse.Initialise function in Main Activity.java file (See Screenshot)[MainActivity.java][1] Question 1: The app_id env variable in parse. Initialise corresponds to app id set in index.js file of parse server example question2: If my configuration is correct then why is the app not storing the data object on the server.?How to check if App has established contact with the server.Android Builds shows no errors. Also the Parse dashboard shows no change in data i.e. data is not being stored on parse server by app.My ultimate goal is to send Push Notification to the server. I have configured my app to GCM, got and configured app and server with correct GCM Project no. (Sender Id) and API key. Please tell what I am doing wrong? Or what needs to be done for get the server and app properly configured.
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hal_kumar.testapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<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="com.example.hal_kumar.testapp" />
</intent-filter>
</receiver>
<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:5XXXXXXXXXX6" />;<!--GCM PROJECT NO -->
</application>
<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="com.google.android.c2dm.permission.RECEIVE" />
<!--
GET_ACCOUNTS is only required for GCM on devices running Android lower than
4.0.4. You may leave out this permission if you are targetting 4.0.4+.
-->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
android:name="com.example.hal_kumar.testapp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.example.hal_kumar.testapp.permission.C2D_MESSAGE" />
</manifest>
index.js (Parse server)
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: 'XXXX',
masterKey: process.env.MASTER_KEY || 'XXXXX', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
push:{
android: {
senderId: '58XXXXXXXXXX26',
apiKey: 'AIXXXXXXO4'
}
}
});
[1]: http://i.stack.imgur.com/NnRwn.png
回答1:
The possible reason for your problem can only be of internet permission.Try to build the project by placing permission code before the begin of code for application in manifest.
Moreover,I would recommend you to use firebase instead of parse since parse is going to dead soon in 2017.
来源:https://stackoverflow.com/questions/38073429/parse-server-configuration-with-android-app