城市飞艇推送通知不推数据 [英] Urban Airship push notification is not pushing the data

查看:111
本文介绍了城市飞艇推送通知不推数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的城市飞艇,和整合这对我的Andr​​oid应用程序。得到样品源从飞艇,我跟着同样的程序,以调用飞艇到我的应用程序。但每当我发送推送通知,我不能让它在我的设备。我在我的源代码一样,我给在飞艇给出的包名。任何人都可以指导我如何融入城市飞艇的android应用。

  AirshipConfigOptions选项= AirshipConfigOptions.loadDefaultOptions(本);

    //可选,定制你的配置在运行时:
    //
    // options.inProduction = FALSE;
     options.developmentAppKey =我的钥匙;
     options.developmentAppSecret我的钥匙;

    UAirship.takeOff(这一点,选项);
    Logger.logLevel = Log.VERBOSE;

    //使用CustomPushNotificationBuilder指定自定义布局
    CustomPushNotificationBuilder NB =新CustomPushNotificationBuilder();

    nb.statusBarIconDrawableId = R.drawable.icon_small; //自定义状态栏图标

    nb.layout = R.layout.notification;
    nb.layoutIconDrawableId = R.drawable.icon; //自定义布局图标
    nb.layoutIconId = R.id.icon;
    nb.layoutSubjectId = R.id.subject;
    nb.layoutMessageId = R.id.message;

    //自定义播放的声音在收到推送时,
    //nb.soundUri = Uri.parse(android.resource://+ this.getPackageName()+/+ R.raw.cat);

    PushManager.shared()setNotificationBuilder(NB)。
    PushManager.shared()setIntentReceiver(IntentReceiver.class)。

}
 

而我编译上面的codeI正在逐渐

 电子03-19 16:13:35.455:ERROR / AndroidRuntime(1247):未捕获的处理程序:由于未捕获的异常螺纹主力退出
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.XYZ}:android.util.AndroidRuntimeException:requestFeature()必须添加内容之前调用
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.app.ActivityThread.access $ 1800(ActivityThread.java:112)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1692)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.os.Handler.dispatchMessage(Handler.java:99)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.os.Looper.loop(Looper.java:123)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.app.ActivityThread.main(ActivityThread.java:3948)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在java.lang.reflect.Method.invokeNative(本机方法)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在java.lang.reflect.Method.invoke(Method.java:521)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:782)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在dalvik.system.NativeStart.main(本机方法)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):android.util.AndroidRuntimeException:产生的原因requestFeature()必须添加内容之前调用
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:281)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在com.XYZ.onCreate(ManualUpdate.java:86)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
03-19 16:13:35.545:ERROR / AndroidRuntime(1247):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
 

解决方案

尝试airshipconfig.properties文件添加到资产,:

  developmentAppKey =键
developmentAppSecret =关键
productionAppKey =关键
productionAppSecret =关键
inProduction =真
运输= C2DM
c2dmSender =电子邮件
 

和删除:

  options.developmentAppKey =我的钥匙;
options.developmentAppSecret我的钥匙;
 

从code。

怎么样的Andr​​oidManifest.xml?您是否设置正确?

 <! -  REQUIRED  - >
    <接收器的Andr​​oid版本:NAME =com.urbanairship.CoreReceiver>
        <! -  REQUIRED的IntentFilter  - 氦和混合 - >
        <意向滤光器>
          <作用机器人:名称=android.intent.action.BOOT_COMPLETED/>
          <作用机器人:名称=android.intent.action.ACTION_SHUTDOWN/>
        &所述; /意图滤光器>
    < /接收器>

    <! - 所需的C2DM和混合 - >
    <接收器的Andr​​oid版本:NAME =com.urbanairship.push.c2dm.C2DMPushReceiver
            机器人:权限=com.google.android.c2dm.permission.SEND>
      <! - 收到实际的消息 - >
      <意向滤光器>
          <作用机器人:名称=com.google.android.c2dm.intent.RECEIVE/>
          <类机器人:名称=com.XXXXXXXX/>
      &所述; /意图滤光器>
      <! - 收到的注册ID  - >
      <意向滤光器>
          <作用机器人:名称=com.google.android.c2dm.intent.REGISTRATION/>
          <类机器人:名称=com.XXXXXXXX/>
      &所述; /意图滤光器>
    < /接收器>

    <! -  REQUIRED  - >
    <  - 在安卓进程的!参数是可选的。将其设置为一个值开始
        用冒号(:),使其在一个独立的运行,
        私人过程 - >
    <服务机器人:名称=com.urbanairship.push.PushService
            机器人:工艺=:com.urbanairship.push.process/>

    <! - 可选的,如果您想接收推,推打开,登记完成意图 - >
    <接收器的Andr​​oid版本:NAME =com.XXXXXXXXXX.service.IntentReceiver/>
 

请记住,你应该总是看到UrbanAirShip一些日志信息。一个特别的注册信息。同时检查如果你的设备添加到城市网站的设备。

I am new to urban airship, and integrating this to my Android application. Got sample source from Airship, and i followed same procedure in order to invoke airship into my application. but whenever i send push notification, i cant get it through my device. The package name what i given in my source same i gave in Airship. can anyone guide me how to integrate the Urban Airship in android application.

   AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);

    // Optionally, customize your config at runtime:
    //
    // options.inProduction = false;
     options.developmentAppKey = "My Key";
     options.developmentAppSecret "My key";

    UAirship.takeOff(this, options);
    Logger.logLevel = Log.VERBOSE;

    //use CustomPushNotificationBuilder to specify a custom layout
    CustomPushNotificationBuilder nb = new CustomPushNotificationBuilder();

    nb.statusBarIconDrawableId = R.drawable.icon_small;//custom status bar icon

    nb.layout = R.layout.notification;
    nb.layoutIconDrawableId = R.drawable.icon;//custom layout icon
    nb.layoutIconId = R.id.icon;
    nb.layoutSubjectId = R.id.subject;
    nb.layoutMessageId = R.id.message;

    // customize the sound played when a push is received
    //nb.soundUri = Uri.parse("android.resource://"+this.getPackageName()+"/" +R.raw.cat);

    PushManager.shared().setNotificationBuilder(nb);
    PushManager.shared().setIntentReceiver(IntentReceiver.class);

}

while i compile the above code i am getting

e   03-19 16:13:35.455: ERROR/AndroidRuntime(1247): Uncaught handler: thread main exiting due to uncaught exception
03-19 16:13:35.545: ERROR/AndroidRuntime(1247): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.XYZ}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.os.Looper.loop(Looper.java:123)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.app.ActivityThread.main(ActivityThread.java:3948)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at java.lang.reflect.Method.invokeNative(Native Method)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at java.lang.reflect.Method.invoke(Method.java:521)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at dalvik.system.NativeStart.main(Native Method)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:281)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at com.XYZ.onCreate(ManualUpdate.java:86)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
03-19 16:13:35.545: ERROR/AndroidRuntime(1247):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)

解决方案

Try to add "airshipconfig.properties" file to assets with:

developmentAppKey = key
developmentAppSecret = key
productionAppKey = key
productionAppSecret = key
inProduction = true
transport = c2dm
c2dmSender = email

and remove the:

options.developmentAppKey = "My Key";
options.developmentAppSecret "My key";

from your code.

What about the AndroidManifest.xml? Did you set up it right?

       <!-- REQUIRED -->
    <receiver android:name="com.urbanairship.CoreReceiver">
        <!-- REQUIRED IntentFilter - For Helium and Hybrid -->
        <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED" />
          <action android:name="android.intent.action.ACTION_SHUTDOWN" />
        </intent-filter>
    </receiver>

    <!-- REQUIRED for C2DM and Hybrid -->
    <receiver android:name="com.urbanairship.push.c2dm.C2DMPushReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
      <!-- Receive the actual message -->
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          <category android:name="com.XXXXXXXX" />
      </intent-filter>
      <!-- Receive the registration id -->
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
          <category android:name="com.XXXXXXXX" />
      </intent-filter>
    </receiver>

    <!-- REQUIRED -->
    <!-- The 'android:process' parameter is optional. Set it to a value starting
        with a colon (:) to make it run in a separate,
        private process -->
    <service android:name="com.urbanairship.push.PushService"
            android:process=":com.urbanairship.push.process"/>

    <!-- OPTIONAL, if you want to receive push, push opened and registration completed intents -->
    <receiver android:name="com.XXXXXXXXXX.service.IntentReceiver" />

And remember that you should always see some logs information from UrbanAirShip. A specially registration information. Check also if your device was added to devices on urban website.

这篇关于城市飞艇推送通知不推数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆