2016-07-12 8 views
0

こんにちは私のローカルシステムでパースサーバーとパースダッシュボードを実行することができます。同じシステム内にあるパースサーバーに自分のアンドロイドアプリケーションを接続しようとしています.Iは、Herokuのに解析・サーバーをホストしていないですか、他のホスティングsite.Iは取得/ローカルパーズサーバーとパーズダッシュボードを通じてプッシュ通知

curl -X POST \ 
    -H "X-Parse-Application-Id:<App_ID>" \ 
    -H "Content-Type: application/json" \ 
    -d '{"Name":"<Name>","Score":<Score>}' \ 
http://localhost:1337/parse/classes/Player 

でもない、私のアンドロイドから解析・サーバーを接続することができ、このコマンドを使用してcomandlineからメッセージを送信することができていますアプリ。

MongoDBは、サーバ-例を解析し、解析し、ダッシュボードが正しくworking.My Androidのコードです:ファイル

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
      package="com.parse.pushnotification" > 

      <uses-permission android:name="android.permission.INTERNET" /> 
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
     <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
      <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
     <permission 
       android:name="<my_Package>.C2D_MESSAGE" 
       android:protectionLevel="signature" />   
     <uses-permission android:name="<my_Package>.permission.C2D_MESSAGE" />  

      <application 
       android:name=".PushParseServerTest" 
       android:allowBackup="true" 
       android:label="@string/app_name" 
       android:theme="@style/AppTheme" > 

       <activity 
        android:name=".MainActivity" 
        android:label="@string/app_name" > 
        <intent-filter> 
         <action android:name="android.intent.action.MAIN" /> 

         <category android:name="android.intent.category.LAUNCHER" /> 
        </intent-filter> 
       </activity> 

<meta-data 
      android:name="com.parse.push.gcm_sender_id" 
      android:value="id:<gcm_project_id>" /> 

       <service android:name="com.parse.PushService" /> 

       <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_package_name>" /> 
        </intent-filter> 
       </receiver> 
       <receiver 
        android:name="<my_package>.ParsePushnotificationReceiver" 
        android:exported="false" > 
        <intent-filter> 
         <action android:name="android.intent.action.BOOT_COMPLETED" /> 
         <action android:name="android.intent.action.USER_PRESENT" /> 
         <action android:name="com.parse.push.intent.RECEIVE" /> 
         <action android:name="com.parse.push.intent.DELETE" /> 
         <action android:name="com.parse.push.intent.OPEN" /> 

         <category android:name="<my_package_name>" /> 
        </intent-filter> 
       </receiver> 
      </application>  
     </manifest> 

Build.gradle マニフェストファイル

{ 

    compile 'com.android.support:appcompat-v7:22.2.0' 
    compile 'com.parse.bolts:bolts-tasks:1.3.0' 
    compile 'com.parse:parse-android:1.13.0' 
} 

PushParseServerTest.java

public class StarterApplication extends Application { 
    @Override 
    public void onCreate() { 
    super.onCreate(); 
    // Enable Local Datastore. 
    Parse.enableLocalDatastore(this); 

    // Add your initialization code here 
    //Parse.initialize(this); 

     Parse.initialize(new Parse.Configuration.Builder(getApplicationContext()) 
       .applicationId("@string/parse_app_id") 
       .clientKey("@string/parse_client_key") 
       .server("http://<my_system_ip>:1337/parse/") // '/' important after 'parse' 
       .build());  
    } 
} 

ParsePushnotificationReceiver.java

public class ParsePushnotificationReceiver extends BroadcastReceiver { 
    private static final String TAG = "ParsePushnotificationReceiver"; 
    // public static final String intentAction = "com.parse.push.intent.RECEIVE"; 

    @Override 
    public void onReceive(Context context, Intent intent) { 
     if (intent == null) { 
      Log.d(TAG, "Receiver intent null"); 
     } else { 
      // Parse push message and handle accordingly 
      Log.d(TAG, intent.getExtras().toString()); 
     } 
    } 
} 

答えて

0

サーバーを解析するためにプッシュ通知や保存のオブジェクトの問題ですか?

parse-serverでプッシュ通知を正しく設定してアンドロイドデバイスを正しく登録しましたか?

+0

私はあなたが/コマンドを使用してcomandlineからメッセージを送信することができます/私はこのメッセージを送信することができます正しくparse-serverを構成したanswer.yesを共有していただきありがとうございます。しかし、私はこのapi Parseで起こっていないアンドロイドデバイスの登録と思います。 initialize()。アンドロイドアプリのトラフィックを確認する方法を教えてください。 –

+0

私はAndroidの専門家ではありません。私はあなたにここでお手伝いするのに最適ではないかもしれません。私が見たことから、多くの人々がそれを稼働させることができました。 https://github.com/ParsePlatform/parse-server/issues/の問題を見逃すことをお勧めしますが、修正のヒントがあるでしょう;) – flovilmart