Android 共享前必须呼叫城市飞艇起飞(仅适用于kit kat)

Android 共享前必须呼叫城市飞艇起飞(仅适用于kit kat),android,urbanairship.com,Android,Urbanairship.com,我试图学习如何使用城市飞艇发送推送通知,为此,我创建了一个非常简单的虚拟应用程序 该应用程序有一个自定义自动驾驶仪和一个自定义通知工厂,以测试一些功能。它在api版本>19的androids上运行良好 但是,对于版本为19(我需要支持的最低版本)的设备,自动驾驶仪从未初始化,因此,每当我尝试访问uautoppilot.shared()…时,应用程序就会出错崩溃 必须在共享前调用起飞 甚至调用Autopilot.autoTakeoff(应用程序)也不能解决这个问题 主要活动: 自动驾驶仪: 客

我试图学习如何使用城市飞艇发送推送通知,为此,我创建了一个非常简单的虚拟应用程序

该应用程序有一个自定义自动驾驶仪和一个自定义通知工厂,以测试一些功能。它在api版本>19的androids上运行良好

但是,对于版本为19(我需要支持的最低版本)的设备,自动驾驶仪从未初始化,因此,每当我尝试访问
uautoppilot.shared()…
时,应用程序就会出错崩溃

必须在共享前调用起飞

甚至调用
Autopilot.autoTakeoff(应用程序)
也不能解决这个问题

主要活动:

自动驾驶仪:

客户通知工厂:


你在舱单上登记自动驾驶仪吗

在应用程序条目中:

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


我正在这样做,是的。我发现,出于某种原因,如果我没有
airshipconfig.properties
文件,它会把kit-kat搞砸,自动驾驶仪根本无法工作。所以我做的是创建了那个文件,然后用我的自定义自动驾驶仪覆盖我需要的内容听起来你可能把元数据输入搞错了。确保其位于清单的应用程序部分内,且值为包名+类名。classes包应该位于文件的顶部,但这不可能,原因有二:它在除19以外的其他api版本中运行良好;如果我创建了一个
airshipconfig.properties
文件,即使我覆盖了自定义自动驾驶仪中的所有内容,它也能在每个版本上工作,包括api 19I。在更改应用程序包名称后,我遇到了这个错误。忘记更新中的包请从此邮件中删除密钥/机密您是否可以发布完整的清单、完整的自动驾驶仪类和build.gradle文件?以及您的应用程序类(如果适用)。
class CustomAutopilot extends Autopilot {

@Override
public void onAirshipReady(UAirship airship) {
    Logger.info("onAirshipReady");
    airship.getPushManager().setUserNotificationsEnabled(true);
    airship.getPushManager().setNotificationFactory(new CustomNotificationFactory(UAirship.getApplicationContext()));
}

@Nullable
@Override
public AirshipConfigOptions createAirshipConfigOptions(@NonNull Context context) {
    Logger.info("setting airship config options");
    AirshipConfigOptions options = new AirshipConfigOptions.Builder()
            .setDevelopmentAppKey("xxxxxxxxxxx")
            .setDevelopmentAppSecret("xxxxxxxxxxx")
            .setDevelopmentLogLevel(Log.DEBUG)

            .setInProduction(false)

            .setGcmSender("232973289571")

            .setNotificationIcon(R.drawable.icon)
            .setNotificationAccentColor(Color.rgb(0, 72, 51))
            .build();
        return options;
    }
}
public class CustomNotificationFactory extends NotificationFactory {
    public CustomNotificationFactory(@NonNull Context context) {
        super(context);
    }

    @Nullable
    @Override
    public Notification createNotification(@NonNull PushMessage message, int notificationId) {
        NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(getContext())
                .setContentTitle("altered " + message.getTitle())
                .setContentText(message.getAlert())
                .setSmallIcon(message.getIcon(getContext(), R.drawable.icon))
                .setColor(Color.rgb(212, 45, 198))
                .setVibrate(new long[]{100, 50, 100, 200, 100, 50, 100})
                .setPriority(Notification.PRIORITY_MAX);

        return builder.build();

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