簡體   English   中英

IBM MobileFirst 7.0-使用觸發器概念的Http適配器調用

[英]IBM MobileFirst 7.0 - Http Adapter Invocation using trigger concept

我們可以使用IBM Mobilefirst中的觸發器來調用Http適配器嗎?

我正在研究基於位置的服務和推送通知集成部分,例如當使用進入Geofench區域時,我們需要調用推送適配器將通知發送到移動設備。

Geofenche代碼:

dwellArea: { // alert when we have stayed in the vicinity for 3 seconds
                        type: "DwellInside",
                        circle: {
                            longitude: pos.coords.longitude,
                            latitude: pos.coords.latitude,
                            radius: 50
                        },
                        dwellingTime: 3000,
                        callback: function() {
                            alert('Still in the vicinity');

在這里我們可以調用Http Adapter調用,即push Adapter見下文:

                            WL.Client.transmitEvent({ event: 'dwell inside area'}, true);
                        }
                    }

推送通知代碼:

var invocationData = {adapter : "PushAdapter",
                                       procedure : "submitNotification",
                                       parameters : [ "Vinod", "Hello This is Push notification" ]
                                     };
                            var options = {
                                    onSuccess : onGetAccountsSuccess,
                                    onFailure : onGetAccountsFailed,
                                    timeout : 30000
                                };
                            WL.Client.invokeProcedure(invocationData, options);

我們可以直接在Geofench編碼的此調用中直接調用此推送通知代碼,還是有其他替代解決方案?

參考鏈接:

地理位置: https//developer.ibm.com/mobilefirstplatform/documentation/getting-started-6-3/advanced-topics/location-services-hybrid-applications/

推送通知: https : //developer.ibm.com/mobilefirstplatform/documentation/getting-started-6-3/notifications/push-notifications-hybrid-applications/#whatIsPushNotifications

我不清楚這個問題...為什么不創建類似

function sendNotification() {
   // your push code...
}

而不是alert()使用sendNotification();
你嘗試過嗎?

您在這里確實有不同的選擇。 如果您要做的只是傳輸一個事件,則無需聲明回調。 您可以將事件添加到觸發器定義中; 例如:

      eventToTransmit: { 
         event: { 
            field1: "data1",
            field2: ["data2", "data3"]
         },
         transmitImmediately: true 
      }

請注意,這將嘗試立即傳輸事件(以及任何以前未傳輸的事件)。 如果您具有動態數據,則需要回調並使用WL.Client.transmitEvent API。 在這兩種情況下,如果都存在通信問題,它將根據事件傳輸策略重試。 您可以在服務器端適配器中處理事件。 請注意,使用事件使您可以分別更新服務器端的邏輯,而無需更新客戶端邏輯。 您還可以處理來自多個不同適配器的事件,而無需它們相互調用。

或者,您可以執行調用以調用適配器中的過程。 在這種情況下,如果存在任何通信問題,則需要聲明一個故障處理程序並在該處實現任何重試邏輯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM