Need help in worklight development - ibm-mobilefirst

I have issue in calling api in worklight .
dont know how and where to call api.
need to get mobile imei number of the mobile .
I also need to get coordinates of mobile , Draw map using lt lg.
kindly help me .

know how and where to call api
That really depends on the API. Ask a proper question...
You need to mention what is your MobileFirst version, too...
need to get mobile imei number of the mobile
This depends on the platform, for example Apple no longer allows to obtain the iPhone/iPad's IMEI number. For Android the following should work:
var deviceInfo = cordova.require("cordova/plugin/DeviceInformation");
deviceInfo.get(
function(result) {
console.log("result = " + result);
},function() {
console.log("error");
});
Draw map using lt lg
Unclear what you're asking...
get coordinates of mobile
Find a Cordova plug-in that provides this.

Related

expo - react native - web | mobile . Looking for Map implementation

I am building a product using expo, a common code base for mobile as well as web. I need to implement a map. Can you please suggest to me the correct npm package or any document to use open street map API. or any other system?
If you just want to display the maps without any direction feature, then you could use react-native-maps.
If you want to show maps with direction feature, you would use react-native-maps-direction. But you'll need to provide google api key to use it.

How to get the MAC address --hybrid app

We have a hybrid apps and would like to track users clicks and need to identified unauthenticated users..
I am thinking about using the MAC id but it's seems to be deprecated in ios7..
However, I see that MobileFirst has an option to get a device id using
WL.Device.getID()
Please advise if this option would work to get a unique ID or if there is a method to get the MAC id..
Thanks for your help
I don't know what is your MobileFirst version, but for this exact need you can use the Operational Analytics feature provided by IBM MobileFirst with its API, that allows you custom tracking... See here: http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.monitor.doc/monitor/c_op_analytics_overview.html?lang=en

How can I access track/album art from local music from the Spotify API?

I am in the process of building an app using the Spotify API as a learning project for myself.
The purpose of the app is to provide a web based remote control for Spotify so I can control a running instance of Spotify on my desktop using a phone or tablet. The Spotify app talks to my Python web server using websockets so I've gotten the core remote control functionality working fine, but I am running into a separate issue.
In the Spotify app, when it encounters a local file (player.track.local = true), player.track.image returns an empty string. When playing a Spotify hosted track, player.track.image always returns a URI in the form of "spotify:image:...". I know that the Spotify Desktop app can see the album art because it displays in the player on the bottom left. I just can't access it for use in my app.
Is there any way to retrieve this art (or failing that a path to the local file so I can go get it myself from the Python server?) Thanks.
-Jeremy
I figured that was the case.
Since I was running into other issues with the new API (such as no longer allowing access to now playing info) i decided to stick with the old API and I was able to make it work from there. I took advantage of the fact that playlists generate a cover image from their contents, so I just did the following:
(I updated this to reflect some simplification I did after spending some time learning more about arrays today)
function getLocalArt() {
sp.core.library.createPlaylist("tempPL");
var mosaicURI;
var trackURI = player.track.uri;
sp.core.library.getPlaylistsUri().forEach(function (p) {
if (p.name == "tempPL") {
p.add(trackURI);
mosaicURI = p.cover;
sp.core.library.removePlaylist(p.uri);
}
});
return mosaicURI;
}
This works rather well for my purposes and returns a string that looks like this:
spotify:mosaic:localfileimage%3AZ%253A%255CiTunes%255CiTunes%2520Media%255CMusic%255CBroken%2520Social%2520Scene%255CEarCande.com%255CAll%2520To%2520All%2520(Skeet%2520Skeet%2520Remix).mp3
This has a side benefit of providing me with the full path to the track in the file system, which I can pass to my server so I can use that to extract album art for display in my web remote. I understand that the use of sp.core is verboten for apps being distributed to the public, but it works for my little project. Thanks.
In short: no - local files' album art is not stored in the backend and the client doesn't expose local data.

How does Twitter get its geolocation data?

I was wondering if anyone knew how Twitter (or facebook) gets its geolocation data, like the various streets and possible buildings. It seems like Twitter gets it from Google, but does anyone know of any resources on how to set that up?
Thanks!
Matt Mueller
Google doesn't parse from all locations either it seems. At least this seems not to work from Curacao. I'm working on a solution that is more stable. See my open question for details. If you just want google you can use this.
Include
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
JS
if(google.loader.ClientLocation) {
latitude = (google.loader.ClientLocation.latitude);
longitude = (google.loader.ClientLocation.longitude);
}
It does it through the HTML5 Geolocation API that is now supported by most modern browsers. Of course it is up to the browser's implementation of the interface to decide how to determine the location. A cell phone will figure it out very differently from a desktop machine, etc. For instance, Firefox uses a Google web service to do it based on the IP address, while Mobile Safari would use Core Location.
A quick Google search will turn up lots of information how to detect and use the capability.

twitter bot with api

im writing a bot that replies to a user message instantly. from what i've read their api only allows checking updates every minute or so.
it's there a push feature or a 3rd party service that pushes the new message to my server right away?
i've seen bots that can do this.
Twitter allows white listing of apps. Then you are only limited to something like 20 or 200 thousand requests an hour. You might want to contact them.
You can look at tweebot python micro framework.
A Python library to build twitter bots over tweepy library. It's a very simple
and flexible way to create your own bot.
First apply for Developper Twitter Account.
And setup your app using the official list of librairies. (python, js and many others available)
If you are using JS, you might not want to use Twit because it is only working with v1.1. You might prefer Twitter-api-v2 but be careful as for now, media upload is not available on v2.
I advise you request an Elevated access from your Developer personal space, which is immediate, and will allow you to use v1 functionalities.
Here is a sample for tweeting an image using twitter-api-v2 (using Elevated account with v1)
import { TwitterApi } from 'twitter-api-v2';
import { twitterconf } from './conf.js';
const client = new TwitterApi({
appKey: twitterconf.CONSUMER_KEY,
appSecret: twitterconf.CONSUMER_SECRET,
accessToken: twitterconf.ACCESS_TOKEN_KEY,
accessSecret: twitterconf.ACCESS_TOKEN_SECRET
});
const image = await client.v1.uploadMedia('/path/to/image.png');
const newTweet = await twitterClient.v1.tweet('Hello World!',
{ media_ids: image });