您是否試過遵循AWS Mobile Hub的新集成指令? imgur.com/a/s9BaW
剛上市,似乎是從你的列表中丟失了一些東西:
您需要添加搖籃依賴性在build.gradle
(版本可能會有所不同)
compile 'com.google.android.gms:play-services-plus:7.8.0'
compile 'com.amazonaws:aws-android-sdk-sns:2.2.18'
指定谷歌服務版本到AndroidManifest.xml中
<meta-data android:value="@integer/google_play_services_version" />
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
註冊一個意向接收器GCM聽GCM notfications
<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.yourapp.package}" />
</intent-filter>
</receiver>
<service
android:name=".PushListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
註冊設備收到推送通知
final PushManager pushManager = AWSMobileClient.defaultMobileClient()
.getPushManager();
pushManager.registerDevice();
// if registration succeeded.
if (pushManager.isRegistered()) {
pushManager.setPushEnabled(enabled);
} else {
// ... handle error, likely due to no network available ...
}
final PushManager pushManager = AWSMobileClient.defaultMobileClient()
.getPushManager();
pushManager.registerDevice();
// if registration succeeded.
if (pushManager.isRegistered()) {
pushManager.setPushEnabled(enabled);
} else {
// ... handle error, likely due to no network available ...
}
註冊爲主題
final PushManager pushManager = AWSMobileClient.defaultMobileClient()
.getPushManager();
pushManager.subscribeToTopic(pushManager.getDefaultTopic());
有你遵循AWS Mobile Hub進行嘗試新的集成指令? http://imgur.com/a/s9BaW – donkon