【发布时间】:2015-09-09 19:03:48
【问题描述】:
我已经在 android/ios 环境中使用 worklight + AngularJs 开发了推送通知,并且我在这两个平台上都获得了成功的通知。
我的应用程序有多个 HTML 页面。每当我从通知栏单击收到的通知时,它都会重定向到默认的 index.html 页面,但我希望它重定向任何其他 (HTML) 内部页面。我也关注了一些与此问题相关的LINK,但它显示了我们是否在单个 html 文件中有代码。但在我的情况下,我有多个 HTML,我不知道如何实现这个场景。
我知道你们中的许多人认为这是一个重复的问题,但我认为这种情况有些不同。
下面是我在 main.js 中的广播通知代码
function wlCommonInit(){
angular.element(document).ready(function() {
// Boot up
angular.bootstrap(document, ["myMobile"]);
});
WL.Client.connect({onSuccess: connectSuccess, onFailure: connectFailure});
}
function connectSuccess() {
WL.Logger.debug ("Successfully connected to MobileFirst Server.");
}
function connectFailure() {
WL.Logger.debug ("Failed connecting to MobileFirst Server.");
//1st snippet
WL.SimpleDialog.show("Push Notifications", "Failed connecting to MobileFirst Server. Try again later.",
[{
text : 'Reload',
handler : WL.Client.reloadapp
},
{
text: 'Close',
handler : function() {}
}]
);
}
//2nd snippet. For the 3rd one copy the adapter
//------------------------------- Handle received notification ---------------------------------------
WL.Client.Push.onMessage = function (props, payload) {
WL.SimpleDialog.show("Tag Notifications", "Provider notification data: " + JSON.stringify(props), [ {
text : 'Close',
handler : function() {
WL.SimpleDialog.show("Brodcast Notifications", "Application notification data: " + JSON.stringify(payload), [ {
text : 'Close',
handler : function() {}
}]);
}
}]);
};
下面的代码是我的 angularJS route.js:
angular.module('MyMobile').
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when("/login", {
templateUrl: "partials/login.html",
controller: "loginController"}
).
when("/home/:activePanelId", {
templateUrl: "partials/home.html",
controller: "homeController"}
).
when("/activity", {
templateUrl: "partials/home.html",
controller: "homeController",
activetab: "activity"}
).
when("/messages", {
templateUrl: "partials/home.html",
controller: "homeController",
activetab: "messages"}
).
when("/membership", {
templateUrl: "partials/membership.html",
controller: "membershipController"}
).
when("/documentrequest", {
templateUrl: "partials/documentRequest.html"/*,
controller: "documentRequestController"*/}
).
when("/findprovider", {
templateUrl: "partials/findProvider.html",
controller: "findProviderController"}
).
when("/benefitsearch", {
templateUrl: "partials/benefitSearch.html",
controller: "benefitController"}
).
when("/benefitsearchresults", {
templateUrl: "partials/benefitSearchResults.html",
controller: "benefitController"}
).
when("/medicine", {
templateUrl: "partials/medicine.html",
controller: "medicineController"}
).
when("/ehr", {
templateUrl: "partials/ehr.html",
controller: "ehrController"}
).
when("/preauthorization", {
templateUrl: "partials/preAuthorization.html",
controller: "preAuthorizationController"}
).
otherwise({redirectTo: '/login'});
}]);
注意:当我点击通知栏中的通知时,我想重定向到“/messages”。
【问题讨论】:
标签: android ios angularjs ibm-mobilefirst