Get device Id from Mobile First - ibm-mobilefirst

I added the above code in main.js inside the wlCommonInit function.
var options = {
onSuccess: succ,
onFailure: fail
};
WL.Device.getID(options);
function succ(data) {
alert('succ ' + JSON.stringify(data));
}
function fail() {
alert('fail');
}
But I am getting Uncaught TypeError: WL.Device.getID is not a function error in desktop web console.
Is it possible to add this code in other js files?
Please suggest!!

Per the documentation, this API method is not available in Desktop browsers. It is available only for mobile devices: http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.apiref.doc/html/refjavascript-client/html/WL.Device.html%23getID
Supported environments: Android, iOS, WindowsPhone8, Blackberry, Blackberry10.

Since you see it in Desktop web console, I take it you are trying out Desktop Browser environment/ Mobile Web app.
This API is not applicable in either case. It works only on Android, iOS, WindowsPhone8, Blackberry, Blackberry10. For more details refer to KnowledgeCenter.

Related

Running html only if running in Electron.js [duplicate]

I'm trying to serve real react app on electron app. It doesn't mean I'm developing electron app with react. I've created a react app and injected it into electron app. (Like slack, it will serve as a web application and desktop application.) But I'm confused that send desktop notifications.
Now the main question is:
How can I get the application type. I mean, is user using my app on web or on desktop. How can I get this?
Thank you :)
There are many ways to detect whether you are running in a desktop environment or not.
You can check the User-Agent and you can set the userAgent value in Electron when you call loadURL.
Another way is declaring a global variable using a preload script.
// main process
new BrowserWindow({
webPreferences: {
preload: "preload.js",
},
});
// preload.js
// you don't need to use contextBridge if contextIsolation is false
// but it's true by default in Electron 12
const { contextBridge } = require("electron");
contextBridge.exposeInMainWorld("IN_DESKTOP_ENV", true);
// renderer process (your React world)
if (globalThis.IN_DESKTOP_ENV) {
// do something...
}

How to Activate AppCheck on React Native in Debug

I am following the documentation https://rnfirebase.io/app-check/usage to use appcheck on React Native.
When I am testing in on my Emmulator, It is not responding to the realtime database requests.
All the requests are showing as unverified requests in firebase appcheck console.
When I went through the documentation : https://rnfirebase.io/app-check/usage#activate
It is written that :
On Android, App Check is not activated until you call the activate method. The provider is not configurable here either but if your app is "debuggable", then the Debug app check provider will be installed, otherwise the SafetyNet provider will be installed.
But process not given, how to activate ?
can some one please help me.
activate api is documented here https://rnfirebase.io/reference/app-check#activate
You can check a sample implementation in their e2e test script.
try {
await firebase.appCheck().activate();
// await firebase.appCheck().activate('ignored');
// await firebase.appCheck().activate('ignored', false);
} catch (e) {
console.log(e);
}

React Native: How to open a Bitcoin URL?

How do you open a Bitcoin URL in a react native app? I am using React Native Linking to detect if there are any apps on the phone that can open a Bitcoin URL formatted according to BIP21. I have 3 apps installed that should handle it:
1) Coinbase
2) Breadwallet
3) Blockchain.info wallet
But it's not opening. Here's the code:
async _openWallet() {
const coinURL = 'bitcoin:15bMc6sQTiQ5jSqoRX3JzatAbQqJaffqup';
try {
const supported = await Linking.canOpenURL(coinURL);
if (supported) {
Linking.openURL(coinURL);
} else {
console.log('Could not find a compatible wallet on this device.');
}
} catch (error) {
console.log(error);
}
}
supported keeps returning false, which causes "Could not find a compatible wallet..." to execute. The weird thing is if I click on a Bitcoin URL on any random website via the Chrome / Safari browser, I get a popup that asks me if I want to open the URL in one of the above apps. So only URLs on websites are opening, but not URLs from inside react native code.
Any ideas?
Looks like every URI scheme you want to use at runtime must be defined up-front in Info.plist. Found the answer here: React Native: Linking API not discovering Uber app

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.