2016-08-01 6 views
0

parse 1.13.0을 nodechef.com에서 사용하고 있는데 알림을 보내도록 설정했지만 몇 가지 문제가 발생했습니다.구문 분석을 사용하여 응용 프로그램에서 푸시 알림

<?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> 
내 응용 프로그램 클래스의

내가 가진 :

내 매니페스트입니다 ParseInstallation.getCurrentInstallation()를 saveInBackground();.

  • DeviceToken는 _Installation 클래스 비어
  • 내가 설치 채널을 사용하는 모든 사용자 또는 일부 사용자에게 통지하고 싶은 어떤 행동, 내가 필요로 내 응용 프로그램에서 푸시 알림을 보낼 수 있습니다

작동하지 푸시 . "구문 분석 푸시"또는 gcm을 사용할 지 신경 쓰지 마세요. 앱에서 푸시 알림을 보내는 간단한 방법이 필요합니다.

수정 푸시 - 대시 보드에서 푸시가 작동하지만 클라이언트에서 푸시 알림을 보낼 수 없습니다. 나는 밀어 넣기를 시도하고 "unauthorized : master key를 사용 가능하게"했다. 그래서 내가 뭘해야하니?

편집 2 나는 구름 코드를 생성하지만 외모 request.params에서 GET 값을 작동하지 :

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 
    } 
}); 
+1

무엇이 문제입니까? 더 많은 코드를 공유 할 수 있습니까? –

+0

@RanHassid 문제에 대한 추가 정보를 추가했습니다. –

+0

parse.com 또는 parse-server를 사용하십니까? –

답변

1

그것을 조사 비트 나는 밀어 보내기를 보내려면 클라우드 코드 기능을 생성하고 마스터 키를 사용해야 함을 알아 차렸다. (userMasterKey = true 보내기 푸시 기능에 대한 매개 변수입니다. 나는 나의 대답을 here에 묘사하고있다. 그래서 그 단계를 거쳐 가면 좋을 것이다.

+0

Tks Ran, CLI 도구를 발견했습니다. 그러나 나는 스크립트를 배포하는 방법을 알고 싶습니다. (전에는 해 본 적이 없으며 크래시 기본 설정이 걱정됩니다.) –

+0

구문 분석 서버를 배포하면 클라우드 코드 스크립트도 배포됩니다. 클라우드 코드 스크립트는 클라우드 폴더 아래에 있어야합니다. 모든 클라우드 코드 기능을 만들 수 있습니다. –

+0

배포하기 전에 모든 코드를 가져와야합니다. 글쎄, 나는 노드 js에 대한 정보를 배포, 소스 등을 다운로드 배우는 것이 필요합니다 ... –

관련 문제