Direct Update error FAILURE_UNZIPPING - android

We are customizing the DirectUpdate process as in the documentation (https://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/dev/c_customizing_direct_update_ui_android_wp8_ios.html - with a directUpdateCustomListener) but in the onFinish callback the status is FAILURE_UNZIPPING.
I am testing on an Android (5.1.1) emulator.
function wlCommonInit(){
WL.Client.connect({
onSuccess: function() {
console.log("Successfully connected to Worklight Server.");
}, onFailure: function() {
console.log("Failed connecting to Worklight Server.");
}
});
}
var busyInd = new WL.BusyIndicator('content');
var savedDirectUpdateContext = null;
var restartDirectUpdate = function () {
if (savedDirectUpdateContext != null) {
savedDirectUpdateContext.start(directUpdateCustomListener); // use saved direct update context to restart direct update
}
};
var directUpdateCustomListener = {
onStart: function(totalSize) {
busyInd.show();
},
onProgress: function(status, totalSize, completeSize) {},
onFinish: function(status) {
busyInd.hide();
console.log("[MFP - DirectUpdate] Finish status: " + status);
var posSuccess = status.indexOf("SUCCESS");
if (posSuccess > -1) {
WL.Client.reloadApp();
} else {
WL.SimpleDialog.show('Update Failed', 'Press try again button', [{
text: "Try Again",
handler: restartDirectUpdate // restart direct update
}]);
wl_directUpdateChallengeHandler.submitFailure();
}
}
};
wl_directUpdateChallengeHandler.handleDirectUpdate = function(directUpdateData, directUpdateContext) {
savedDirectUpdateContext = directUpdateContext
WL.SimpleDialog.show('Update Avalible', 'Press Update button to download the new version!', [{
text : 'Update',
handler : function() {
directUpdateContext.start(directUpdateCustomListener);
}
}, {
text : 'Cancel',
handler : function() {
wl_directUpdateChallengeHandler.submitFailure();
}
}]);
};
How can we fix this?

The custom code is working fine without zxing installed. I suggest that you will try the same without this library. If it works, I suspect that it may be initializing or otherwise interfering with the Direct Update process once an update has been received.
Considering loading the library later in the app life cycle and see if this helps.

Related

Bluetooth background scanning not working when the app is background in cordova application

I am initializing the blueeothle and peripheral using the foll code:-
bluetoothle.initialize(function initializeResult(result) {
console.log(result);
}, {
request: true,
statusReceiver: true,
restoreKey: "bluetoothleplugin",
});
bluetoothle.initializePeripheral(
function initializeResult(result) {
console.log("initialize peripheral");
console.log(result);
},
function error(result) {
console.log("init peripheral error");
console.log(result);
},
{
request: true,
restoreKey: "bluetoothleplugin",
}
);
and I started the scan using the foll options:-
bluetoothle.startScan(
(result: BluetoothScanResult) => {
console.log("result in searching");
// console.log(result);
if (result.name) {
bluetoothresult.push(result);
resulllt.push(result);
bluetoothresultconst.push(result);
resullltconst.push(result);
}
},
function startScanErrorCallback(err) {
console.log("printing err");
console.log(err);
},
{ serviceUuids: [],allowDuplicates:true }
);
setTimeout(() => {
bluetoothle.stopScan(
(result) => {
console.log("stopping the scanning");
console.log(bluetoothresult);
if (bluetoothresult.length != 0) {
console.log("got result length is more than zero");
}
},
function stopScanErrorCallback(result) {
console.log("came error in stopping the scanning ");
console.log(result);
}
);
}, 40000);
I am getting the scan results fine but when i moved the application to background using the following code:-
cordova.plugins.backgroundMode.moveToBackground();
i was getting empty results for the scan .Ive kept the interval for scan as 60000ms and 40000ms timeout for stopping
but immediately when the app is made to run in foreground scan results were fine.
Note:-I am cheking the applicaiton in a Android 9 device ive even added permission for foreground service in manifest.xml of the cordova and plugin.xml also

FCM Push notification didn't receive when app is in foreground but receive when app in background

Push notification not receive when App is in foreground but receive while App in background i have followed FCM tutorial from https://medium.com/#ankushaggarwal/gcm-setup-for-android-push-notifications-656cfdd8adbd
Try in this way and implementing this plugin.
And when device ready I fired this code:
pushNotification.register(
function (result) {
//Do some stuff
}, function (error) {
//Do some stuff on error
}, {
"badge":"true",
"sound":"true",
"alert":"true",
"ecb": "onNotificationAPN"
});
And also implemented below function:
function onNotificationAPN(event) {
if (event) {
if ( event.alert ) {
alert(Recieved alert: + event.alert);
}
if ( event.sound ) {
var snd = new Media(event.sound);
snd.play();
}
if ( event.badge ) {
pushNotification.setApplicationIconBadgeNumber(function() {
//SetApplicationIconBadgeNumber success.
}, function() {
//SetApplicationIconBadgeNumber error.
},
event.badge);
}
}
}

Cordova / Android - Can't login with Facebook

I am trying to log my users with Facebook, but can't figure out how to do it.
This is the code I have so far :
facebookConnectPlugin.getLoginStatus(
function(status) {
if (status.status != "connected") {
facebookConnectPlugin.login(
['public_profile', 'email'],
function(success) {
console.log("Success", success);
},
function(error) {
console.log("Error", error);
}
);
}
else {
console.log("logging status : ", status.status);
}
},
function(error) {
console.log("Getting logging status failed : ", error);
}
);
On my Android device, I do not have the Facebook app installed, and I am not logged into Facebook on any browser.
I would expect the facebookConnectPlugin.login() method to popup the login form, but instead this is what it returns :
Which basically means : "You did not enter. You are not connected to Facebook. Enter Facebook and try again".
I looked into this Meteor plugin to see how they were doing it, but they respect the exact same logic.
I am not sure what to do from here. Any suggestion is most welcome !
you can try code for get Login Status read more here
var fbLoginSuccess = function (userData) {
alert("UserInfo: " + JSON.stringify(userData));
facebookConnectPlugin.getLoginStatus(
function (status) {
alert("current status: " + JSON.stringify(status));
}
);
};
you can try code for get User Profile.
facebookConnectPlugin.login( ["public_profile","email"],
function (response) {
if(response.authResponse.userID!=''){
facebookConnectPlugin.api(response.authResponse.userID+"/?fields=id,email,first_name", ["public_profile"],
function (response) {
console.log('SUCCESS:'+response);
alert('first_name : '+response.first_name+',email:'+response.email+',id:'+response.id);
},
function (response) {
console.log('ERROR:'+response);
});
}
},
function (response) {
console.log('ERROR:'+response);
});
let me know if its not working...

Ionic admob implementation using floatinghotpot cordova-plugin-admob

I'm following this tutorial for having banner ads in my android application.
https://blog.nraboy.com/2014/06/using-admob-ionicframework/
The problem is that I get an error callback from the plugin which is only telling me :
Invalid action
I ran the cordova plugin add for the plugin, I modified the admob publisher id, I used the sample code from the tutorial right above but it always get stuck in the second callback function which is the error case callback.
Here is the code I used :
var admobApp = angular.module('myapp', ['ionic'])
.run(function($ionicPlatform, $ionicPopup) {
$ionicPlatform.ready(function() {
if(window.plugins && window.plugins.AdMob) {
var admob_key = device.platform == "Android" ? "ANDROID_PUBLISHER_KEY" : "IOS_PUBLISHER_KEY";
var admob = window.plugins.AdMob;
admob.createBannerView(
{
'publisherId': admob_key,
'adSize': admob.AD_SIZE.BANNER,
'bannerAtTop': false
},
function() {
admob.requestAd(
{ 'isTesting': false },
function() {
admob.showAd(true);
},
function() { console.log('failed to request ad'); }
);
},
function() { console.log('failed to create banner view'); }
);
}
});
});

JSONStore code not working

I am trying to learn JSONStore and in process of that I am trying to execute a piece of code which will first check if a particular JSONStore is already there in the device or not and based on the result it will execute if-else statement. If it is not there, it will create one and add some data in it. In case the jsonStore is already present, code will replace the previously stored data with new data. But when I am trying to execute the code, my device shows the html contents for a while and then the screen gets blank. When I checked the logcat, I didn't get any of my console log statements which I have added in my code. Can anyone please help me in understanding this behavior and what could be done to achieve the requirement.
var JSONStoreCollections = {};
var collectionName = 'Person';
function wlCommonInit(){
require([ "layers/core-web-layer", "layers/mobile-ui-layer" ], dojoInit);
}
function dojoInit() {
require([ "dojo/ready", "dojo/parser", "dojox/mobile", "dojo/dom", "dijit/registry", "dojox/mobile/ScrollableView" ], function(ready) {
ready(function() {
if(!(WL.JSONStore.get(collectionName))){
console.log("i am in if codition");
var Data={
Name:'name',
Age:27
};
JSONStoreCollections[collectionName] = {};
JSONStoreCollections[collectionName].searchFields = {Name: 'string'};
WL.JSONStore.init(JSONStoreCollections)
.then(function () {
console.log("store created");
})
.fail(function (errorObject) {
console.log("store creation failed");
});
WL.JSONStore.get(collectionName).add(Data)
.then(function () {
console.log("data added");
})
.fail(function (errorObject) {
console.log("data addition failed");
});
var query = {Name: 'name'};
WL.JSONStore.get(collectionName)
.find(query)
.then(function (arrayResults) {
console.log(arrayResults);
WL.Logger.debug(arrayResults);
})
.fail(function (errorObject) {
console.log(errorObject);
WL.Logger.debug(errorObject);
});
}
else{
var Data1={
Name:'name1',
Age:30
};
WL.JSONStore.get(collectionName).replace(Data1)
.then(function () {
console.log("data replaced");
})
.fail(function (errorObject) {
console.log("data replacement failed");
});
var query = {Name: 'name1'};
WL.JSONStore.get(collectionName)
.find(query)
.then(function (arrayResults) {
console.log(arrayResults);
WL.Logger.debug(arrayResults);
})
.fail(function (errorObject) {
console.log(errorObject);
WL.Logger.debug(errorObject);
});
}
});
});
}
You need to initialize first, otherwise WL.JSONStore.get(collectionName) will always return undefined. If you never initialize JSONStore, you can not use it.
The replace API works with JSONStore documents (objects that have keys for _id and json).
You only need one .fail, the error object will tell you the source of the error (errorObject.src).
See the untested pseudocode below for what you want to do:
function wlCommonInit () {
var collectionName = 'Person';
var Data = {
Name: 'name',
Age: 27
};
var JSONStoreCollections = {};
JSONStoreCollections[collectionName] = {};
JSONStoreCollections[collectionName].searchFields = {Name: 'string'};
WL.JSONStore.init(JSONStoreCollections)
.then(function () {
WL.Logger.debug('Init done');
return WL.JSONStore.get(collectionName).findAll();
})
.then(function (res) {
WL.Logger.debug('Find All returned:', res);
if (res.length < 1) {
return WL.JSONStore.get(collectionName).add(Data);
} else {
res[0].json = {
Name:'name1',
Age:30
};
return WL.JSONStore.get(collectionName).replace(res[0]);
}
})
.then(function () {
WL.Logger.debug('Add or Replace done');
return WL.JSONStore.get(collectionName).find({Name: 'name'});
})
.then(function (res) {
WL.Logger.info('Final Find returned:', res);
})
.fail(function (err) {
WL.Logger.error(err);
});
}
Expected output the first time executed:
Init done
Find All returned: []
Add or Replace done
Final Find returned: [{"_id":1,"json":{"Name":"name","Age":27}}]
Expected output other than the first time executed:
Init done
Find All returned: [{"_id":1,"json":{"Name":"name","Age":27}}]
Add or Replace done
Final Find returned: [{"_id":1,"json":{"Name":"name1","Age":30}}]

Categories

Resources