使用Android应用解析服务器配置 [英] Parse server configuration with android app

查看:79
本文介绍了使用Android应用解析服务器配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近按照PARSE SERVER Example存储库中的github指令在机器上设置了本地解析服务器.我的服务器已启动并且正在运行,我在Main Activity.java文件中包含了Parse.Initialise函数(请参见截图)[MainActivity.java] [1] 问题1:解析中的app_id env变量.初始化对应于解析服务器示例的index.js文件中设置的应用程序ID 问题2:如果我的配置正确,那么为什么应用程序不将数据对象存储在服务器上?如何检查应用程序是否已与服务器建立联系Android Builds没有显示错误.解析仪表板也显示数据没有变化,即应用没有将数据存储在解析服务器上,我的最终目标是将推送通知发送到服务器.我已将我的应用程序配置为GCM,并使用正确的GCM项目编号获得并配置了应用程序和服务器. (发件人ID)和API密钥.请告诉我我做错了吗?或者需要做些什么才能正确配置服务器和应用程序.

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.

  <?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(解析服务器)

     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

推荐答案

出现问题的可能原因仅是Internet权限.尝试通过将权限代码放在清单中应用程序代码的开头之前来构建项目.

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.

此外,我建议您使用Firebase代替parse,因为解析将在2017年终止.

Moreover,I would recommend you to use firebase instead of parse since parse is going to dead soon in 2017.

这篇关于使用Android应用解析服务器配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆