2016-08-21 3 views
0

amazon aws sdkを使用しており、プッシュ通知が機能するようにしようとしていますので、Google開発者コンソールでプロジェクトを設定してから GCM GCM登録IDを取得できなかったというアプリを実行しようとしましたが、ここで他の同様の質問を検索した後、私のマニフェストが正しく設定されていることを確認しました。(Unity AWS SDK)Googleクラウドメッセージング登録IDを取得するためにfaudしました

<?xml version="1.0" encoding="utf-8"?> 
<manifest 
xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.amazonaws.unity" 
    android:installLocation="preferExternal" 
android:versionCode="1" 
android:versionName="1.0"> 

    <supports-screens 
    android:smallScreens="true" 
    android:normalScreens="true" 
    android:largeScreens="true" 
    android:xlargeScreens="true" 
    android:anyDensity="true"/> 

    <uses-sdk android:minSdkVersion="9" /> 


    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
    <uses-permission android:name="android.permission.WAKE_LOCK" /> 
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"  /> 

    <permission android:name="com.amazonaws.unity.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 
    <uses-permission android:name="com.amazonaws.unity.permission.C2D_MESSAGE" /> 


    <application 
    android:theme="@android:style/Theme.NoTitleBar" 
    android:icon="@drawable/app_icon" 
    android:label="@string/app_name" 
    android:debuggable="true"> 

    <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" 
      android:label="@string/app_name"> 
    <intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 
    <category android:name="android.intent.category.LAUNCHER" /> 
    <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> 
    </intent-filter> 
    <meta-data android:name="unityplayer.UnityActivity" android:value="true" /> 
    <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" /> 
    </activity> 

    <receiver 
    android:name="com.google.android.gcm.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.amazonaws.unity" /> 
    </intent-filter> 
    </receiver> 

    <service android:name="com.amazonaws.unity.GCMIntentService" /> 
    </application> 
    </manifest> 

登録ID取得するコードの一部:ここ

は、マニフェストファイルのConfiguring the Unity Sample App for Androidに与えられた手順を実装する前に

 if(string.IsNullOrEmpty(GoogleConsoleProjectId)) 
     { 
      Debug.Log("sender id is null"); 
      debug.text = "sender id is null"; 
      return; 
     } 
     GCM.Register((regId) => 
     { 

      if(string.IsNullOrEmpty(regId)) 
      { 
       ResultText.text = string.Format("Failed to get the registration id"); 
        debug.text = "Failed to get the registration id"; 

       return; 
      } 

      ResultText.text = string.Format(@"Your registration Id is = {0}", regId); 

      SnsClient.CreatePlatformEndpointAsync(
       new CreatePlatformEndpointRequest 
       { 
        Token = regId, 
        PlatformApplicationArn = AndroidPlatformApplicationArn 
       }, 
       (resultObject) => 
       { 
        if(resultObject.Exception==null) 
        { 
         CreatePlatformEndpointResponse response = resultObject.Response; 
         _endpointArn = response.EndpointArn; 
         ResultText.text += string.Format(@"Platform endpoint arn is = {0}", response.EndpointArn); 
        } 
       } 
      ); 
     }, GoogleConsoleProjectId); 

答えて

1

を、あなたは以下のを持っていることを確認してくださいAndroidの必要条件Amazon Simple Notification Service

  • JDK
  • アンドロイド・サポート・v4.jar
  • グーグルプレイ-services.jarに

Unity Sample (Android)に与えられた概念に注意してくださいインストールのAndroid SDK
  • をインストールします。

    通知の登録の登録を解除する通知の登録ボタンをタップすると、RegisterDevice()メソッドが呼び出されます。 RegisterDevice()GCM.Registerを呼び出し、アプリをGCMに登録します。アプリをGCMに登録するための非同期呼び出しが行われます。

    AWSのドキュメントに加えて、Unity SNS exampleに関するこのAWSディスカッションフォーラムをチェックすることもできます。

  • +0

    私はそのスレッドにリダイレクトしてくれてありがとう、私もそこに私の質問を投稿しました。 はい、私は私のプロジェクトでこれらの4つを持っており、google-play-servicesについてもそうです。 jarは最新のリビジョン30以降、googleは私が古いものを使用しているので、小さなものにGoogle Playサービスライブラリを分離することを決めました(29)。また、私はガイドのすべてのステップに従って、私はawsが提供するデモSNSシーンを使用しています –

    関連する問題