Preview not working properly in MFP8.0 - ibm-mobilefirst

I'm developing an application that just connects to MFP 8.0 server but when I run the app using the MFP web simulator the log says "getCachedAccessToken for scope failed: undefined" . But when I run the same application using the emulator/device it works fine.
function wlCommonInit() {
WLAuthorizationManager.obtainAccessToken().then(
function () {
alert ("You are now connected to the server");
},
function(result) {
alert("Not able to connect: "+ JSON.stringify(result));
}
);
}
Is there any way to test the MFP server connection in the MFP web simulator?

This is a known limitation of the 8.0 release.
You can read more about it, here: http://engtest01w.francelab.fr.ibm.com:9090/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.dev.doc/wl_studio_tools/topics/cmbswl.html
Tokens are part of the OAuth flow.
As a workaround, you can use a simulator.

Related

Unable to Register IOS device to Mobile First 8

I am able to see the iOS device under devices tab in MF, registered to my application. but pushing a notification fails with the below error:
An error occurred while the notification was sent. Internal server error. No devices found.
Upon reviewing IOS code, I noticed the below issue while invoking MFPPush.sharedInstance.registerDevice(nil)
Cannot retrieve a valid authorization header for header. Check resource and authorization server configuration.
I am using the code from the git sample. Below is the snippet throwing the error:
#IBAction func registerDevice(_ sender: AnyObject) {
print("Attempting Device registration with Mobile First")
WLAuthorizationManager.sharedInstance().obtainAccessToken(forScope: "push.mobileclient") { (token, error) -> Void in
if (error != nil) {
print("Did not recieve an access token from server: " + error.debugDescription)
} else {
WLClient.sharedInstance()?.setDeviceDisplayName("White Ipad", withCompletionHandler: { (error) in
if error == nil{
print("device display name is set")
}else{
print("error setting device name: " + error.debugDescription)
}
})
print("Recieved the following access token value: " + (token?.value ?? "no token"))
MFPPush.sharedInstance().registerDevice(nil) { (response, error) -> Void in
if error == nil {
self.enableButtons()
self.showAlert("Registered successfully with Mobile First")
print(response?.description ?? "")
} else {
self.showAlert("Registration failed with Mobile First. Error \(error?.localizedDescription)")
print(error?.localizedDescription ?? "")
}
}
}
}
}
Mobile First Config: I have followed the documentation and configured the UserLogin security check from the sample git project and have removed scope to push.mobileclient under security.
Reading the OAuth Security in MF, i understand the that token is necessary to access resources, but I am unable to figure out how to attach the token in registerDevice().
It seems to be you haven't configured Push Notifications properly in MobileFirst Server.
Make sure that you have added push.mobileclient scope in Security tab of your application. If you are not using any security check, you can add scope like below.
Check whether your application is configured valid iOS provisioning profile enabled with Push Capability
Make sure that you have uploaded valid sandbox/production certificates in Push tab of your particular app in MFP Operations Console.
More details : here
Make sure your app is enabled Push Capability in the project setting and also check you sending device token to MF Server using MFPPush.sharedInstance().sendDeviceToken(deviceToken) API in didRegisterForRemoteNotificationsWithDeviceToken method of AppDelegate file
-

How to invoke WL.client.init API for MFP v8

I upgrade my cordova app to MFP v8 latest iFIx (8.0.0.00-20170220-1900) and now I am not able to connect to MFP from my cordova app.
In Xcode , I see the error
WebKit discarded an uncaught exception in the
webView:didFinishLoadForFrame: delegate: <Illigal API call> IBM
MobileFirst Platform framework is not initialized. [WL mainHtmlFilePath]
API should be used after the successful callback of the
[WL initWithDelegate:]
API. This is to ensure that IBM MobileFirst Platform framework
initialization is complete and web resources are ready to be used.
This is my snippet of the call
try {
WL.Client.init(wlInitOptions);
} catch (err) {
console.error('MFP: "WL" init error - ' + err);
initFailure(err);
}
var wlInitOptions = {
timeout: 1000,
onConnectionFailure: initFailure,
onFailure: initFailure,
onSuccess: function () {
console.log('MFP: Loaded');
initDeferred.resolve();
connectToMobileFirst();
}
};
The onSuccess or Failure method is never called.
Thanks for your help

Was able to push logs but failed while calling WLClient.connect()

I am working on IBM MobileFirst client being android native app.
I have a weird issue I am writing the following code to initialize WLClient.
WLClient client = WLClient.createInstance(context);
client.connect(new WLResponseListener() {
#Override
public void onSuccess(WLResponse wlResponse) {
Log.d("Success--- MFP_connect",wlResponse.getResponseText());
}
#Override
public void onFailure(WLFailResponse wlFailResponse) {
Log.d("fail-- MFP_connect",wlFailResponse.getErrorMsg());
}
});
In My android Monitor I see a log saying
fail-- MFP_connect: The service is currently not available.
But when I am trying to push logs or analytics to the server. They are reaching the server successfully.
I am connecting to http enterprise server.
What could be the issue.
#rocky solved his issue by uninstalling the app and reinstalling. The device may have been caching the previous response.

MobileFirst Platform Foundation 7.0 event listeners not working properly

I upgraded a simple hybrid Worklight project from 6.3 to 7.0. The majority of functionality is fine. However, listeners for WL.Events.WORKLIGHT_IS_CONNECTED and WL.Events.WORKLIGHT_IS_DISCONNECTED no longer function properly.
Here is the code:
function wlCommonInit(){
WL.Client.connect({onSuccess: onConnectSuccess, onFailure: onConnectFailure});
function onConnectSuccess() {
WL.Logger.debug("Connect success.");
}
function onConnectFailure() {
WL.Logger.debug("Connect failed.");
}
$("body").resize();
//Added listeners for Online/Offline functionality and set heart beat
document.addEventListener(WL.Events.WORKLIGHT_IS_CONNECTED, connectDetected, false);
document.addEventListener(WL.Events.WORKLIGHT_IS_DISCONNECTED, disconnectDetected , false);
WL.Client.setHeartBeatInterval(10);
initJson();
}
// Online/Offline Functions
function connectionFailure(){
alert("Could not connect to the MobileFirst Server.");
var output = "OFFLINE";
$('#ConnectionMsg').html(output);
}
function disconnectDetected(){
var output = "<font color='red'>DISCONNECTED</font>";
$('#ConnectionMsg').html(output);
}
function connectDetected(){
var output = "<font color='green'>CONNECTED</font>";
$('#ConnectionMsg').html(output);
if(initialConnection){
initialConnection = false;
} else {
setTimeout(function(){
//cleanDirtyDocs();
}, 20000);
}
}
Simply, the application has a footer that says "CONNECTED" or "DISCONNECTED" based on the WORKLIGHT_IS_CONNECTED and WORKLIGHT_IS_DISCONNECTED events. This works perfectly in WL6.3, but the exact same code does not work in 7.0. There is no message after initialization, just a blank footer, and the only way to get DISCONNECT to display is to call an adapter after the server is down. CONNECT is never displayed.
This makes no sense and is easy to replicate. Was there a change in how these events work? Thanks!
This is a known issue with the MFP v7.0 release. an iFix release is planned to address it. At this time there is no workaround.
Please open a PMR (support ticket) so that the fix could be delivered to you.
You can mention "APAR PI38012" for the support team to find it.

flex 4.6 : Application crash if no internet connection

My mobile application is interact with WCF web services i build it in flash builder with Data/Services then put the url in the WSDL services
my issue is if the mobile starts with no internet connection it crashed
the error message in the console
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::rawChildren_getChildIndex()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemManager.as:2187]
at mx.managers::SystemRawChildrenList/getChildIndex()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemRawChildrenList.as:181]
at spark.components.supportClasses::StyleableStageText/getFormIndex()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableStageText.as:1956]
at spark.components.supportClasses::StyleableStageText/findTopmostForm()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableStageText.as:1933]
at spark.components.supportClasses::StyleableStageText/updateProxyImageForTopmostForm()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableStageText.as:2172]
at spark.components.supportClasses::StyleableStageText/commitProperties()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableStageText.as:1510]
at mx.core::UIComponent/validateProperties()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:8219]
at mx.managers::LayoutManager/validateClient()
at mx.managers::LayoutManager/validateClient()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:950]
at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:382]
at mx.managers::PopUpManager$/addPopUp()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\PopUpManager.as:193]
at spark.components::SkinnablePopUpContainer/open()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\SkinnablePopUpContainer.as:450]
at debug.ondevice.util::EnterDebugHostIPDialog/show()[/ndepot/fb_46_release_branch/ide_builder/com.adobe.flashbuilder.launching.multiplatform.contributor/utilswcs/src/debug/ondevice/util/EnterDebugHostIPDialog.mxml:47]
at debug.ondevice.util::DebuggerHostInfo$/showIPErrorDialog()[/ndepot/fb_46_release_branch/ide_builder/com.adobe.flashbuilder.launching.multiplatform.contributor/utilswcs/src/debug/ondevice/util/DebuggerHostInfo.as:129]
at mx.netmon::NetworkMonitorImpl/ioErrorHandler()[/ndepot/fb_46_release_branch/ide_builder/com.adobe.flexbuilder.monitors.network/netmonlibrary/src/mx/netmon/NetworkMonitorImpl.as:645]
i want to handle this error with message if no connection
i tried to put condition for internet connection when creation complete
protected function view1_creationCompleteHandler(event:FlexEvent):void
{
monitor = new URLMonitor(new URLRequest('http://www.adobe.com'));
monitor.addEventListener(StatusEvent.STATUS, announceStatus);
monitor.start();
}
public function announceStatus(e:StatusEvent):void {
trace("Status change. Current status: " + monitor.available);
(new AlertMsg()).open(this, false) ;
}
but it doesn't reached if no connection
Note : My target is android
Thanks in advance , for any help