- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在 Urban Airship 的帮助下发送推送通知,并且也成功收到了通知。但是当我点击通知时,它并没有打开我的应用程序。那么我可以做什么来打开我的应用程序?
并在 logcate 中收到以下错误:-
02-10 18:53:44.137: W/xxx - UALib(6840): Activity com.aaa.yyy.SplashActivity@40dcb458 was not manually added during onStart(). Call UAirship.shared().getAnalytics().activityStarted in every activity's onStart() method.
最佳答案
是的,在谷歌搜索后我得到了答案:-我们需要创建一个 IntentReceiver.java 类,如下所示:-
public class IntentReceiver extends BroadcastReceiver{
private static final String logTag = "PushSample";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(logTag, "Received intent: " + intent.toString());
String action = intent.getAction();
if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {
int id = intent.getIntExtra(PushManager.EXTRA_NOTIFICATION_ID, 0);
Log.i(logTag, "Received push notification. Alert: "
+ intent.getStringExtra(PushManager.EXTRA_ALERT)
+ " [NotificationID="+id+"]");
logPushExtras(intent);
}else if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
Log.i(logTag, "User clicked notification. Message: " + intent.getStringExtra(PushManager.EXTRA_ALERT));
logPushExtras(intent);
Intent launch = new Intent(Intent.ACTION_MAIN);
launch.setClass(UAirship.shared().getApplicationContext(), MainActivity.class);
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
UAirship.shared().getApplicationContext().startActivity(launch);
}else if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
Log.i(logTag, "Registration complete. APID:" + intent.getStringExtra(PushManager.EXTRA_APID)
+ ". Valid: " + intent.getBooleanExtra(PushManager.EXTRA_REGISTRATION_VALID, false));
}
}
private void logPushExtras(Intent intent) {
Set<String> keys = intent .getExtras().keySet();
for(String key: keys){
List<String> ignoredKeys = (List<String>)Arrays.asList("collapse_key", "from", PushManager.EXTRA_NOTIFICATION_ID,PushManager.EXTRA_PUSH_ID, PushManager.EXTRA_ALERT);
if(ignoredKeys.contains(key)){
continue;
}
Log.i(logTag, "Push Notification Extra: ["+key+" : " + intent.getStringExtra(key) + "]");
} }
}
之后我们需要在 PushNotification.java 中调用以下方法。这是代码。
public class PushNotification extends Application{
@Override
public void onCreate() {
AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);
options.developmentAppKey = "xxx";
options.developmentAppSecret = "yyy";
options.productionAppKey = "zzz";
options.inProduction= false;
UAirship.takeOff(this, options);
PushManager.enablePush();
String apid = PushManager.shared().getAPID();
Logger.info("My Application onCreate - App APID: " + apid);
PushManager.shared().setIntentReceiver(IntentReceiver.class);
}
}
关于android - 单击带有 Urban Airship 的推送通知打开android应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21678395/
我有一个非常简单的问题,但搜索没有让我找到答案。在我的 application:didFinishLaunchingWithOptions 方法中,我执行以下操作来恢复程序未运行时传入的通知: //
我正在从 parse.com 迁移到 Urban Airship ,我几乎完成了,一切正常,但有一件事。当我的应用程序打开时,会向警报 View 发送推送通知不是 正在显示。如果我将应用程序放在 背景
我已按照 UA 教程进行操作并获取了我的 APID,并在我的 Android 设备上成功收到了测试推送消息。 现在我想做的下一件事是使用 JAVA 定位我的设备并发送推送消息。据我目前所知,实现这一目
我正在尝试学习 Urban Airship。看起来很容易,对吧?出色地。我只有两个问题,我似乎无法回答。 首先,我已经在我的用户 ID 下设置了开发中的所有内容。向我的手机发送消息效果很好。惊人的!但
我在我的项目中使用 Urban 飞艇,但是当我编写代码时它显示此错误请给我任何解决方案。 10-15 07:57:54.472: E/AndroidRuntime(1427): FATAL EXCEP
感谢之前的回复, 我们如何通过程序在设备 token 中设置别名和标签。我引用了飞艇文档,我发现我们可以使用 setAliasandTags 函数设置别名和标签,谁能指导我如何在 android 中执
我会逐步说明情况 我已经按照 the guide 实现了 Urban Airship 当消息来自服务器时,我的应用会自动显示通知,这是我不想要的 我想要的是处理来自服务器的消息并能够手动显示我的通知
如何将Android中的通知消息更改为本地化?我只想更改从 Urban AirShip 获得的消息,然后它才会显示在通知栏上? 最佳答案 您可以使用此方法:PushManager.shared().s
我正在考虑实现拇指系统,但我的系统需要注册,因此排除了人们多次投票的可能性,除非他们创建一个新帐户来这样做。所以我想知道 Urban Dictionary 的拇指系统。它是如何工作的?我想我的 IP
感谢之前的回复, 我对 Urban_Airship 很陌生,并将其集成到我的 android 应用程序中,我真的不知道什么是 Urban Airship 的别名,谁能指导我了解什么是别名以及如何在中设
我正在使用 php 客户端向 Urban Airship 发送通知请求。为此,我在下面提到了链接。 https://support.urbanairship.com/entries/70144047-
在创建新的生产 APNS 证书时,Apple 现在会创建一个组合的沙盒和生产证书: 上传到 Urban Airship 时,Urban Airship 报错说它是 Sandbox 证书。 我们已经联系
我正在尝试将 UrbanAirship 集成到我的项目中,但出现以下错误: 2016-08-25 16:26:23.898 Fibre[7758:368753] [E] __52+[UAirship
我想从 Urban Airship 发送的额外键值中获取值。请帮助如何获得这些值。我能够收到推送通知。但我不知道如何从有效负载中获取数据。 public class IntentReceiver ex
我在尝试将 Urban Airship PUSH 通知集成到我的 Android 应用程序时遇到问题。 我认为我已经在 AndroidManifest 集中获得了我的所有权限和 Intent 过滤器,
我已成功实现 Urban airship for development 。我创建了一个生产应用程序并在 airshipConfig 文件中设置 key 和 secret ,其中临时:是。我为生产生成
如何在android中实现 Urban Airship ?我从下载样本 here .我运行我得到安装选项的应用程序。安装后我什么也得不到。其实我不知道如何用android设置 Urban Airshi
我在使用 Urban Airship 时遇到问题,特别是在为 Rich Push 注册用户时。我在 AppDelegate 中有以下代码 //Create Airship options dictio
使用 Xcode 5.0 升级到 UrbanAirship 3.0.0,调用此代码时出现错误: [UAirship takeOff:config]; 错误是 +[NSJSONSerialization
我在安装我的应用程序时收到以下 NPE。请帮忙。 07-22 16:27:06.380: E/UA AP(6071): Unable to takeOff automatically 07-22 16
我是一名优秀的程序员,十分优秀!