2017-05-27 13 views
0

都市庁の通知を統合するためのテストアプリケーションを構築しようとしています。私はhttps://docs.urbanairship.com/platform/android/#getting-startedhttps://michiganlabs.com/2014/01/31/push-notification-urban-airship/に従っているので、私の新しいプロジェクトもFCMに登録します。 APIキーと送信者IDを都市部に登録しています。 (メソッドを解決できません)MainactivityUrbanAirship通知Androidの実装

package jss.urabn; 

import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 

import com.urbanairship.AirshipConfigOptions; 
import com.urbanairship.UAirship; 
import com.urbanairship.push.PushManager; 

public class MainActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this); 
       options.developmentAppKey = 'Your development app key'; 
       options.productionAppKey = 'Your production app key'; 
       options.inProduction = false; 




    } 
} 

私はloaddefaultoptions方法でエラーを得ていないMに対する

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="jss.urabn"> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 


    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:roundIcon="@mipmap/ic_launcher_round" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 

     <!-- Autopilot calls takeOff without the need to override the Application --> 
     <meta-data android:name="com.urbanairship.autopilot" 
      android:value="com.urbanairship.Autopilot"/> 

     <activity android:name=".MainActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 


    </application> 

コード:以下

は、Androidマニフェストのコードです。

誰でもガイドできます。

答えて

1

オートパイロットを使用しているため、airshipconfig.propertiesファイルから直接オプションを取得します。オプションを手動でカスタマイズしようとする場合は、カスタムオートパイロットクラスで行うか、メインアプリケーションをオーバーライドする必要があります。上記のMainActivityにはありません。マニフェストで

<meta-data 
     android:name="com.urbanairship.autopilot" 
     android:value="cjss.urabn.SampleAutopilot"/> 

はその後オートパイロットクラスを定義します。

package jss.urabn; 

public class SampleAutopilot extends Autopilot { 

    @Override 
    public void onAirshipReady(UAirship airship) { 
     airship.getPushManager().setUserNotificationsEnabled(true); 
    } 

    @Nullable 
    @Override 
    public AirshipConfigOptions createAirshipConfigOptions(@NonNull Context context) { 
     AirshipConfigOptions options = new AirshipConfigOptions.Builder() 
       .applyDefaultProperties(context) 
       .setInProduction(!BuildConfig.DEBUG) 
       .setDevelopmentAppKey("Your Development App Key") 
       .setDevelopmentAppSecret("Your Development App Secret") 
       .setProductionAppKey("Your Production App Key") 
       .setProductionAppSecret("Your Production App Secret") 
       .setNotificationAccentColor(ContextCompat.getColor(context, R.color.color_accent)) 
       .setNotificationIcon(R.drawable.ic_notification) 
       .build(); 

     return options; 
    } 
} 

AirshipConfigクラスは不変に変更されました。あなたはビルダーを使ってそれを定義する方法を知っています。メソッド 'loadDefaultOptions'は、ビルダーのapplyDefaultPropertiesにマップされます。

関連する問題