ADM客户端未收到消息

时间:2014-11-29 06:32:30

标签: amazon-web-services amazon-sns

我正在尝试将SNS消息发送到Firephone,而我似乎正在发送消息(到某处),似乎没有任何消息传递到我的firephone。

我能够使用文档中的代码创建KindleMobilePushApp,能够生成RegistrationID,我为测试应用程序创建了安全配置文件等等。我假设我必须做对了,如果我我正在获得注册ID。

然后我尝试向手机发送消息,使用Kindle演示应用程序接收消息但似乎没有任何结果,ADMHandler的“onMessage”方法永远不会被调用。

我尝试通过AWS SNS控制台发送消息,并通过文档中提供的java应用程序(sns.samples.mobilepush),Java应用程序似乎正在发布一些东西,但是再一次,它没有通过我的消防电话,或者至少没有被我的接收器课程接收过。

我之前从未使用过SNS,所以我不确定问题出在哪里,我是不是要发送到正确的端点,或者我的应用程序不知道应该收到它应该是的消息获得。 CloudWatch报告“已发布消息”和“消息失败”的号码相同,但实际上并不知道消息发生了什么。

我应该在想什么?在我的清单下面,并发布java发送程序的结果。

<!-- Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.  -->
<!-- Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at -->
<!--     http://aws.amazon.com/apache2.0/ -->
<!-- or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:amazon="http://schemas.amazon.com/apk/res/android"
    package="com.grapevine.snstest"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

   <!-- This permission ensures that no other application can intercept your ADM messages. It
   should have the form packagename.permission.RECIEVE_ADM_MESSAGE where packagename is the
   name defined in the "package" property of the manifest tag. --> 
    <permission android:name="com.grapevine.snstest.permission.RECEIVE_ADM_MESSAGE"
        android:protectionLevel="signature"/>

    <!-- Required permissions -->
    <uses-permission android:name="com.grapevine.snstest.permission.RECEIVE_ADM_MESSAGE"/>
    <uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"        
        android:theme="@style/AppTheme" >
        <uses-permission android:name="com.grapevine.snstest.permission.RECEIVE_ADM_MESSAGE"/>
        <activity
            android:name="com.grapevine.snstest.KindleMobilePushApp"
            android:screenOrientation="portrait"
            android:label="@string/title_activity_main"
            android:launchMode="singleTop" >
            <uses-permission android:name="com.grapevine.snstest.permission.RECEIVE_ADM_MESSAGE"/>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Your application's API Key -->
        <!--<meta-data android:name="AmazonAPIKey" android:value="@string/api_key"/>-->

        <!--  Declare your ADMMessageHandlerBase implementation as a service -->
        <service android:name="com.grapevine.snstest.ADMMessageHandler"
            android:exported="false" />

        <!-- You must explicitly enable ADM. You must also declare whether your application will run with or without ADM.
        If you specify android:required="false", your app must degrade gracefully when ADM is unavailable. -->
        <amazon:enable-feature android:name="com.amazon.device.messaging" 
            android:required="true" />

        <receiver android:name="com.grapevine.snstest.ADMMessageHandler$MessageAlertReceiver"
                  android:permission="com.amazon.device.messaging.permission.SEND">
            <uses-permission android:name="com.grapevine.snstest.permission.RECEIVE_ADM_MESSAGE" />
            <intent-filter>
               <action android:name="com.amazon.device.messaging.intent.REGISTRATION" /> 
               <action android:name="com.amazon.device.messaging.intent.RECEIVE" /> 
               <category android:name="com.grapevine.snstest"/>
            </intent-filter>
        </receiver>       
    </application>

</manifest>

这是我使用MobilePushApp示例程序时的输出:

===========================================

Getting Started with Amazon SNS
===========================================

{PlatformApplicationArn: arn:aws:sns:us-west-2:308914227153:app/ADM/SNSTest}
{EndpointArn: arn:aws:sns:us-west-2:3089xxx53:endpoint/ADM/SNSTest/66xxxf-1f06-3xx1-b887-fxxxxbe19}
{Message Body: {"ADM":"{\"data\":{\"message\":\"Hello World! \"},\"expiresAfter\":1000,\"consolidationKey\":\"Welcome\"}"}}
{Message Attributes:}
Published! 
{MessageId=90f09248-e65b-5713-a6da-debb8e5afcef}

Process finished with exit code 0

1 个答案:

答案 0 :(得分:1)

哎呀,这不起作用,因为在开发人员门户网站上的应用程序上没有启用SNS消息传递。