传递邮件时出错:未找到ServiceIntent

时间:2016-10-10 16:19:39

标签: android service firebase-cloud-messaging amazon-sns firebase-notifications

我正在尝试在我的Android应用中将AWS SNS推送服务与FCM集成。
当我尝试通过SNS在线控制台发送推送消息时,我收到此错误日志:

E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
E/PushListenerService: From: ************ /* My Sender ID*/
E/PushListenerService: Message: hola
E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.

我在网上搜索了一下,我发现似乎是一个非常受欢迎的答案,有3个服务,包括GcmIntentServiceGcmIDListenerServiceRegistrationIntentService。我已将这些类和服务添加到我的应用程序中,但我仍然没有从SNS获得任何推送通知。
我也不确定它是否适合我,因为我不仅使用FCM服务,还使用SNS服务。

这些是我的清单中现有的接收器和服务:

    <receiver android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
            <category android:name="com.intap.appme" />
        </intent-filter>
    </receiver>

    <service android:name=".PushListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        </intent-filter>
    </service>

关于推送通知。当我通过SNS在线控制台发送它时,我收到上述日志错误,但是当我通过Firebase在线控制台发送它时,设备会收到推送通知,但我仍然得到这个日志,这是第一个以及上面日志的最后几行:

E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.

build.gradle依赖项:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'
    compile fileTree(dir: 'libs', include: ['activation.jar'])
    compile fileTree(dir: 'libs', include: ['additionnal.jar'])
    compile fileTree(dir: 'libs', include: ['mail.jar'])
    compile 'com.amazonaws:aws-android-sdk-core:2.2.18'
    compile 'com.amazonaws:aws-android-sdk-s3:2.2.18'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.2.18'
    compile 'com.amazonaws:aws-android-sdk-ddb-mapper:2.2.18'
    compile 'com.amazonaws:aws-android-sdk-ec2:2.2.18'
    compile 'com.google.android.gms:play-services-plus:9.0.1'
    compile 'com.amazonaws:aws-android-sdk-sns:2.2.18'
    compile 'com.google.android.gms:play-services-gcm:9.0.1'
    compile 'com.android.support:multidex:1.0.1'
    apply plugin: 'com.google.gms.google-services'
}

你能帮我解决一下并解决它吗?

4 个答案:

答案 0 :(得分:3)

首先,您应该在不包含依赖关系块之后应用google-services插件。此外,我没有看到任何添加FirebaseInstanceID的依赖项,因此我不确定为什么会出现该错误。同时使用FCM和GCM并不是一个好主意,因为您有相同消息的多个接收器。使用其中一个。这可能就是没有收到sns消息的原因。

答案 1 :(得分:2)

在依赖项部分中将'implementation'com.google.firebase:firebase-messaging:17.4.0'添加到您的应用程序级别build.gradle文件中。

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation'com.google.firebase:firebase-messaging:17.4.0'
}

答案 2 :(得分:1)

添加firebase消息传递依赖项对我来说很有效

Container(
                          margin: EdgeInsets.only(bottom: 10.0),
                          decoration: ShapeDecoration(
                            shape: RoundedRectangleBorder(
                                side:
                                    BorderSide(color: Colors.grey, width: 1.0),
                                borderRadius: BorderRadius.circular(10.0)),
                          ),
                          width: 320.0,
                          child: DropdownButtonHideUnderline(
                            child: ButtonTheme(
                              alignedDropdown: true,
                              child: _buildDropdownButtonAgama(),
                            ),
                          ),
                        ),
                      ],
                  );
        },
      ),

请注意,firebase消息传递依赖于firebase-analytics

答案 3 :(得分:-1)

如果您尝试了所有其他解决方案,但仍然遇到错误,请尝试强制尝试...将以下代码添加到您要求服务或同步地图的代码中。
在Oncreate内尝试添加:

 if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(yourActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION)!= PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(yourActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_REQUEST_CODE);

        }
        else{
            mapFragment.getMapAsync(this);
        }




and inside onConnected method try adding.

if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(yourActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION)!= PackageManager.PERMISSION_GRANTED)
        { 
ActivityCompat.requestPermissions(youractivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION},LOCATION_REQUEST_CODE );

        }