IBM工作灯5.0.6.1 - 没有得到推送通知时,电话/应用程序被关闭 [英] IBM Worklight 5.0.6.1 - Not getting Push Notifications when phone/app is closed

查看:145
本文介绍了IBM工作灯5.0.6.1 - 没有得到推送通知时,电话/应用程序被关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Android的基础推送通知工作一个工作灯混合的应用程序。如果应用程序正在运行,并且在对焦时通报推,它的行为完全按照我期望的那样。在我的应用程序的通知回调被调用时,它会弹出一个SimpleDialog。 所有好

I have a Worklight hybrid app with basic push notification working in android. If the app is running and in focus when the notification is pushed, it behaves exactly as I would expect. The notification callback in my app is called, and it pops up a SimpleDialog. All Good.

如果我解雇应用程序通过点击主页按钮,新邮件到达时,我看到在Android通知区域中的通知,当我在Android通知列表中单击该项目,该项目被从被解雇列表(但应用程序不回来成为关注的焦点),如果我再从程序菜单启动我的应用程序,它坐在那里,我离开它和SimpleDialog正呈现。 (我的通知处理程序被调用)的晴好,但我期望的应用程序来成为关注的焦点时,我选择了Android的通知列表通知。

If I dismiss the app by clicking on the Home Button, and a new message arrives, I see the notification in the Android notification area, and when I click on the item in the android notification list, the item gets dismissed from the list (but the app does not come back into focus) If I then launch my app from the Apps menu, it is sitting where I left it and the SimpleDialog is showing. (my notification handler was called) Mostly good, but I expected the app to come into focus when I selected the notification in the android notification list.

如果我解雇程序通过单击后退按钮,以及一个新邮件到达,我看到在Android通知区域中的通知,当我在Android通知列表中单击该项目,该项目被从被解雇列表(但应用程序不回来成为关注的焦点),如果我再从程序菜单启动我的应用程序,它会启动新的应用程序(我要再次登录)和我的通知处理程序不会被调用。 不太好

If I dismiss the app by clicking on the Back Button, and a new message arrives, I see the notification in the Android notification area, and when I click on the item in the android notification list, the item gets dismissed from the list (but the app does not come back into focus) If I then launch my app from the Apps menu, it launches the app fresh (I have to log in again) and my notification handler is never called. Not so good.

如果我强制停止的应用程序,或者把手机关闭通知正在发送时(但保留认购的地方),通知一直没有出现在手机上。我没有看到它在Android通知区域,当我重新启动手机,当我启动应用程序在我的应用程序的通知处理程序不会被调用。 非常糟糕

If I force stop the app, or turn the phone off while the notification is being sent (but leave the subscription in place), the notification never shows up on the phone. I don't see it in the Android Notification area when I restart the phone, and the notification handler in my app is never called when I launch the app. Very bad.

这是预期的行为?

我用工作灯5.0.6.1,和我见过的平台4.1.2 Android模拟器这种行为在平台4.2.2和物理电话

I'm using Worklight 5.0.6.1, and I've seen this behavior on Android emulator at platform 4.2.2 and a physical phone at platform 4.1.2

EDT:添加code

EDT: Adding the code.

适配器:

WL.Server.createEventSource({
    name : "MyPushEventSource",
    securityTest: "MyApp-strong-mobile-securityTest"
});

function submitNotification(userId) {

    var userSubscription = WL.Server.getUserNotificationSubscription(
            'MyPushNotification.MyPushEventSource', userId);

    if (userSubscription == null) {
        return {
            result : "No subscription found for user :: " + userId
        };
    }

    var notification = WL.Server
            .createDefaultNotification("There's work to be done!", 1, {});

    WL.Server.notifyAllDevices(userSubscription, notification);

    return {
        result : "Notification sent to user :: " + userId
    };
}

和在应用程序:

WL.Client.Push.onReadyToSubscribe = function() {

    var pushSubscribe_Success_Callback = function(response) {
        WL.Logger.debug("Enter: pushSubscribe_Success_Callback");
    };

    var pushSubscribe_Fail_Callback = function(response) {
        WL.Logger.debug("Enter: pushSubscribe_Fail_Callback");
    };

    var pushNotificationReceived = function(props, payload) {

        WL.SimpleDialog.show("Notification", props.alert, [
                { text : "OK" }]);
    };

    WL.Client.Push.registerEventSourceCallback("myPush",
            "MyPushNotification", "MyPushEventSource",
            pushNotificationReceived);

    if (!WL.Client.Push.isSubscribed("myPush")) {

        WL.Client.Push.subscribe("myPush", {
            onSuccess : pushSubscribe_Success_Callback,
            onFailure : pushSubscribe_Fail_Callback
        });
    }
 };

正如我所说的,如果应用程序是焦点,这一切工作顺利,所以我知道我有谷歌邮件帐户和密钥设置正确。但由于某些原因,我看到了意想不到的结果,如果应用程序是不是在对焦时通报公布。

As I said, if the app is in focus, this all works without a hitch, so I know I have the Google messaging account and keys set up correctly. But for some reason I'm seeing unexpected results if the app isn't in focus when the notification is published.

推荐答案

确定。我花了足够长的时间来弄清楚这一个,所以在任何情况下下面,现在的问题是:

OK. It took me long enough to figure this one out, so in case anyone follows, here is the problem:

我已经打开[Android项目] /res/values​​/strings.xml和改变APP_NAME的值改为应用程序。

I had renamed the app by opening [android project]/res/values/strings.xml and changing the value of app_name.

这会导致应用程序时,选择应用程序推送通知不启动。

That causes the app to not launch when a push notification for the app is selected.

我通过更改APP_NAME回到其原始值,并增加对友好名称的新字符串名为app_label解决了这个问题。然后,我走进AndroidManifest.xml中,并改​​变机器人的两个实例:标签=@字符串/ APP_NAME为:机器人:标签=@字符串/ app_label和SHA-ZAM!我的应用程序有一个好记的名称,并点击通知启动它。

I fixed this by changing app_name back to its original value, and adding a new String named app_label for the friendly name. I then went into AndroidManifest.xml, and changed the 2 instances of android:label="@string/app_name" to: android:label="@string/app_label" And sha-zam! My app had a friendly name AND clicking on notifications launched it.

有关好措施我修改push_notification_title在strings.xml中是友好名称,并且改善了通知的显示并没有打破应用程序的启动。

For good measure I modified push_notification_title in strings.xml to be the friendly name, and that improved the display of the notification and did not break the launching of the app.

这篇关于IBM工作灯5.0.6.1 - 没有得到推送通知时,电话/应用程序被关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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