WLResourceRequest is not defined - ibm-mobilefirst

I have created a sample project where I am trying to hit a service which gives the Latitude and Longitude of a particular location. I have already deployed the adapter on the server and now I am trying to hit the adapter. When I try to do so, I get the error: WLResourceRequest is not defined in my js. Following is my code:
function locate() {
var locat = document.getElementById('location').value;
alert(locat);
var resourceRequest = new WLResourceRequest(
"/adapters/LocationAdapter/getGmapLatLng",
WLResourceRequest.GET
);
resourceRequest.setQueryParameter("params", "['110064']");
resourceRequest.send().then(
function(response) {
alert("Success\n\n" + response);
},
function(error) {
alert("Failure\n\n" + error);
}
)
}

Add mfp plugin properly. If already added then remove it and add again.
cordova plugin add cordova-plugin-mfp

In your Config.xml:
Define the plugin like this:
<plugin name="cordova-plugin-mfp" spec="8.0.2016101414"/>
then run the following command:
cordova prepare android
or
cordova platform remove android && cordova platform add android

Related

How can i check app installed in react native code

i tried to check other app install in my react native project, I'm used module like: https://www.npmjs.com/package/react-native-check-app-install
But always got this error:
Cannot read property 'pkgName' of undefined
Here is my code:
AppInstalledChecker
.isAppInstalledAndroid('com.skype.raider')
.then((isInstalled) => {
// isInstalled is true if the app is installed or false if not
console.log('App Skype status: ', isInstalled);
});
Anyone can suggest me one way so check app install in react native (both: iOS/android)
install this
https://github.com/KjellConnelly/react-native-shared-group-preferences
and
async check() {
try {
await SharedGroupPreferences.isAppInstalledAndroid("com.farsitel.bazaar")
// IF IS INSTALL
} catch (e) {
// IF IS NOT INSTALL
}
}
Google Play considers the list of installed apps to be personal and sensitive user data.
As we are using
AppInstalledChecker
.isAppInstalledAndroid()
method for checking app installed check, for that we have to white-list the queries in manifest.xml
Reference : https://developer.android.com/training/package-visibility
<queries>
<package android:name="com.instagram.android"/>
…
</queries>
For adding Queries need to upgrade build gradle version:
new default settings and features for package visibility in Android 11 that need to add  you must update your android gradle plugin version
Reference: How to fix "unexpected element <queries> found in <manifest>" error?
I have updated from 3.5.2 to 4.0.2
Now react-native-check-app-install module working as expected
Hope this is resolved!
Android
I. For app's which has deep links like 'waze://', 'mapsme://' you can use:
import { Linking } from 'react-native'
...
Linking.canOpenURL('waze://ul?ll=${latitude},${longitude}&navigate=yes')
OR
II. You can use for absolutely all apps (for example with deep links like "https://...")
https://github.com/KjellConnelly/react-native-shared-group-preferences
iOS
import { Linking } from 'react-native'
...
Linking.canOpenURL(iOS_app_URL_Scheme)
...
where iOS_app_URL_Scheme you can find via Google for each separate app. Like "waze://", "comgooglemaps://", "osmandmaps://" etc

IBM Mobile first JSONstore is not working 7.1 version

My mobile first studio plugin version is 7.1.0.00-20161006-0540. We have upgraded to the latest iFix IMF 00-20161118-2214 for server.
We just started with the sample code provided in IBM knowledge center for JSONstore, but we got error -11 OPERATION_FAILED_ON_SPECIFIC_DOCUMENT
We called the JSONStore Initialization using JavaScript from WLinit Then only we will get this error -11, if it is in outside of Wlinit it's not showing anything in console.
We already mentioned JSONSTORE in application descriptor file
Finally I find the problem.
Issue was in config.xml
Feature tag name was wrong here. I replaced StoragePluginStoragePlugin to StoragePlugin.
In new iFix also having the same problem.
Thanks
Calling JSONStore from WLInit (in initOptions.js?) is not a place to do the initialize for JSONStore...
You should initialize a JSONStore collection in your main.js, inside function wlCommonInit(), like so:
function wlCommonInit() {
var collections = {
people : {
searchFields: {name: 'string', age: 'integer'}
}
};
WL.JSONStore.init(collections).then(function (collections) {
// handle success - collection.people (people's collection)
alert("success);
}).fail(function (error) {
// handle failure
alert ("failure");
});
}

Using react native with Optimizely

I try to follow documentation in Optimizely to get my react native app (#22.2) working but getting such bug.
MainActivity.java:24: error: cannot find symbol
Optimizely.startOptimizelyWithApiToken("xxxxxx", getApplication());
^
symbol: method startOptimizelyWithApiToken(String,Application)
location: class Optimizely
1 error
:app:compileDebugJavaWithJavac
What is wrong and how can I debug . I try
adb logcat ReactNative:V ReactNativeJS:V
but it's not giving me any information
I an on the engineering team at Optimizely and we've released a brand new product called FullStack that is more geared towards developers. As part of the product we now offer a JavaScript SDK for running experiments in all JavaScript clients, including React Native.
To use you would install our SDK:
npm install optimizely-client-sdk
And then you can split traffic using our activate and track methods.
Here is an example:
var optimizely = require('optimizely-client-sdk');
// Initialize an Optimizely client
var optimizelyClientInstance = optimizely.createInstance({ datafile: datafile });
// ALTERNATIVELY, if you don't use CommonJS or npm, you can install the minified snippet and use the globally exported varible as follows:
var optimizelyClientInstance = window.optimizelyClient.createInstance({ datafile: datafile });
// Activate user in an experiment
var variation = optimizelyClientInstance.activate("my_experiment", userId);
if (variation === 'control') {
// Execute code for variation A
} else if (variation === 'treatment') {
// Execute code for variation B
} else {
// Execute default code
}
// Track conversion event
optimizelyClientInstance.track("my_conversion", userId);
For more information please checkout our developer docs: https://developers.optimizely.com/x/solutions/sdks/introduction/index.html?language=javascript
i sorted problem is more about reading docs and using legacy:
compile ('com.optimizely:optimizely-legacy:+#aar') {
transitive = true
}
and then:
Optimizely.startOptimizely("xxxx", getApplication());

Fatal error when registering global shortcut in Electron

I have tried to register global keyboard shortcut using Electron's global-shortcut module, as per the documentation page. (https://github.com/atom/electron/blob/master/docs/api/global-shortcut.md)
However, I received the following error in my console when I run electron:
[20097:0608/181936:FATAL:global_shortcut_listener_x11.cc(49)] Check failed: BrowserThread::CurrentlyOn(BrowserThread::UI).
I am running Electron on Ubuntu 14.04 LTS. I would like to ask if this error is platform-specific. Are there any steps I missed out from the documentation page? If there isn't, is there any way to get around this error? Thanks.
Your application should be ready before you register your shortcuts.
Here is an example:
var app = require('app');
var globalShortcut = require('global-shortcut');
// Your app must be ready before the registration
app.on('ready', function() {
console.log('Your app is ready!');
// You can now register your shortcuts
globalShortcut.register('ctrl+alt+j', function() {
console.log('You fired ctrl+alt+j !!!');
});
});

Strophe js in Titanium Appcelerator?

I want to create a chat application in Titanium appcelerator using Strophe.js library. I have gone through strophe js libraries and their documents as well. I believe we can use strophe.js to build xmpp based chat app in web.
Thanks in advance, Can anyone please clarify the following doubts,
Is it possible to use strophe js inside our Titanium Appcelerator,If yes please suggest me how to use it. I tried to include the strophe js inside the titanium it shows can't find module error
Here's the code i tried with.
Ti.include("includes/strophe.js");
Ti.include("includes/strophe.register.js");
connection.register.connect("localhost:5280", callback, wait, hold);
var callback = function (status) {
if (status === Strophe.Status.REGISTER) {
connection.register.fields.username = "newuser";
connection.register.fields.password = "123456";
connection.register.submit();
} else if (status === Strophe.Status.REGISTERED) {
console.log("registered!");
connection.authenticate();
} else if (status === Strophe.Status.CONNECTED) {
console.log("logged in!");
} else {
// every other status a connection.connect would receive
}
};
$.index.open();
Can you please suggest to use any other libraries that can be used inside the Titanium Appceleartor to build chat application using XMPP
Looks like Strophe is created to be used inside browser and modifying it to work inside Titanium is rather risky.
The only XMPP module for Titanium, which I could find is titanium-xmpp on GitHub.