感谢以前的回复。
我正在尝试将城市飞艇融入我的应用程序中。对于这个我在urbanairship网站上的注册表并获得了一些凭据,我也得到了测试应用程序的示例程序。即使应用程序正在运行,但是从城市航空网站发送的项目不会显示在通知中。不知道如何实施城市飞艇。任何人都可以帮我解决这个问题。
提前致谢
答案 0 :(得分:1)
您是否添加了此代码?
AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);
options.developmentAppKey = "Your Development AppKey";
options.developmentAppSecret ="Your development AppSecret";
options.productionAppKey = "Your production app key";
options.inProduction = false; // determines which app key to use
UAirship.takeOff(this, options);
Logger.logLevel = Log.VERBOSE;
// use CustomPushNotificationBuilder to specify a custom layout
CustomPushNotificationBuilder nb = new CustomPushNotificationBuilder();
nb.statusBarIconDrawableId = R.drawable.icon; // custom statusbar icon
nb.layout = R.layout.notification;
nb.layoutIconDrawableId = R.drawable.notifyicon; // custom layout icon
nb.layoutIconId = R.id.icon;
nb.layoutSubjectId = R.id.subject;
nb.layoutMessageId = R.id.message;
PushManager.shared().setNotificationBuilder(nb);
PushManager.shared().setIntentReceiver(IntentReceiver.class);
将以下代码添加到您的清单并尝试使用,您必须添加此内容
<!-- Urban AirShip -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- REQUIRED for C2DM -->
<!--
Only this application can receive the messages and registration result
-->
<!--
MODIFICATION REQUIRED - Replace "com.urbanairship.push.sample" with
your package name
-->
<permission android:name="com.urbanairship.pushdemo.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.urbanairship.pushdemo.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- End Urban AirShip -->