Mobilefirst Studio and Bluemix - ibm-mobilefirst

i want to ask a question concerning the integration between Bluemix platform and mobilefirst studio on my local environment.
First i did all the steps in the following link:
http://mbaas-gettingstarted.ng.bluemix.net/hybrid
After i followed the steps i did this in my main.js file
var ibmbluemix,ibmpush;
var values = {
applicationId: "7ecb984c-43e5-4dcab2a0-76aca303ba6d",
applicationRoute: "http://ibm-banktrial2.mybluemix.net"
};
function initPush() {
ibmbluemix=IBMBluemix.hybrid;
ibmpush = IBMPush.hybrid;
ibmbluemix.initialize(values);
}
and then i tried running the application on the android simulator and it's fine no errors happen.
what i want to do now, is that i want this application not to be locally deployed i want it deployed on bluemix, and i want to access the services for this ibm-banktrial2 app on ibmbluemix platform, it contains a service called "Business rules" and it has a rest API that i can't deal with through mobilefirst in the main.js and i couldn't find any useful links.
PS: i made the business rules service instance and i made the rules through eclipse with the plugin for business rules and i deployed it.
what i want is to validate an application request from mobilefirst to access this business rules service which contains the rules for validating a bankloan.
final note: i understood nothing from the following link:
http://www-01.ibm.com/support/knowledgecenter/SSQP76_8.7.0/com.ibm.odm.dserver.rules.ref.res/html/restapi/html/index.html

If I am understanding you correctly you want the application to run on Bluemix? It looks like you are running a hybrid app. The code you have above runs locally on the mobile device. Since you are running a hybrid app you can not run the above code on Bluemix. Bluemix in this case provides a backend for your app.

Related

Restricting FCM credentials to only development apps

I work on several Android and iOS apps with a team of developers. These apps use Push Notifications - through Firebase (FCM) for Android and through APNs for iOS.
For APNs, we use a key (.p8 file) for production servers, and a sandbox-only certificate (.pem file) for testing. Our development team is allowed to use the sandbox for testing push notifications, but cannot accidentally send push notifications to production.
For FCM, we use a Service Account (.json file) for production servers, and we want a way to allow our developers to test push notifications in development without being able to push messages to production.
We have configured our Android apps so that debug builds append .dev to the application ID, like this:
android {
buildTypes {
debug {
applicationIdSuffix '.dev'
}
}
}
In the Firebase console, our project contains both app identifiers com.example.myapp (not the real name) and com.example.myapp.dev as separate apps.
However, I cannot find a way to create a separate Service Account that is limited to sending to the .dev apps.
Is there a way that I can set up a development-only account so my developers can send push notifications only to the development versions of the apps?
For this scenario the only thing I can think would be creating a new Firebase project in order to isolate both environments.
I'm not aware of a way to restrict a service account from sending FCM messages to only a particular app in the project.

MobileFirst Adapters - Why am I getting a "401 Unauthorized" error when making request on Swagger Docs page in the MobileFirst Operations Console

I am using MobileFirst CLI 8.0.0-2016070716, Java 1.8.0_91 (on Mac OS X 10.11.6 if it matters). I have been working through this tutorial on creating Java adapters using MobileFirst CLI.
After following the steps on creating, building, and deploying the adapter, I open the operations console and select the adapter I just deployed --> Resources --> "View Swagger Docs". When I press "Try it out" on any of the operations, I receive a "401 - Unauthorized" response code.
Any idea what problem might be?
"To add a Test Token to the request, so that the security framework skips any security challenges protecting your resource, click the on/off switch button on the right corner of an endpoint's operation.
You will be asked to select which scopes you want to grant to the Swagger UI (for testing purposes, you can select all). If you are using the Swagger UI for the first time, you might be required to log in with a Confidential Client ID and Secret. For this, you will need to create a new confidential client with * as its Allowed Scope."
Documentation regarding this is located here in our getting started tutorials.
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/adapters/testing-and-debugging-adapters/#using-swagger

How to Launch/Open any other external app from hybrid app? [duplicate]

I have a requirement to open the native version of the hybrid app (.ipa/.apk/.appx) when the hybrid app is requested in a device browser.
I am able to detect the environment using WL.Client.getEnvironment(); method, if it is found to be Android/iPad, I want to launch the respective .apk/.ipa file in the device. Any help is appreciated.
Re-reading this question and the comments several times... I still do not understand the actual scenario... it'd be best to rephrase it.
Scenario: How to open an app from the web browser:
If you have added the following environments to your Worklight application:
Mobile Web
Android
iPhone
And when visiting the Mobile Web version of your app, you want to display a message like "For the full experience, open the full application by clicking here".
Then:
It is implied that the user already has the application installed.
If it is not installed, you need to take care of that somehow
The way to handle this scenario is to use URI schemas:
For Android: How to implement my very own URI scheme on Android
This means that after adding the custom URI schema to AndroidManifest.xml, you could then detect the device OS the Mobile Web app is currently running on and display a custom link: myapp://<the URI schema you've defined>. Tapping it will open the app installed on the device.
For iOS, in a similar fashion: https://coderwall.com/p/mtjaeq
Also see: http://wiki.akosma.com/IPhone_URL_Schemes
Alternate solution: If you are not sure if the app will be installed or not, then instead of using URI schemas you can always point to either Google Play or Apple App Store, to the app page; the user will then have either a "Open" or "Install" link.
Scenario: How to open an app from my own app
If you have a Worklight Hybrid application (Mobile Web is not a Hybrid application), and you want to open another application from within it, you can:
Use the same approach of URI schemas, or
Use Cordova plug-ins
I have created this Worklight 6.1.0 project to demonstrate:
Android - How to open, for example, the Android Settings app from your Worklight Hybrid app
iOS - How to check if Waze is installed and open it, and if it is not installed then to open Apple Maps instead.
See instructions.txt in the apps\test folder.
Are you asking that if the user via their device browser hits the webapp version of your app on the internet, the website will ask the user to fire up the native app on their device? kind of like what ebay does?
if that is what you want check out these pages
android:Launch custom android application from android browser
IOS:
iPhone - Open Application from Web Page

Azure App Service Oauth failure after Mobile Service migration

Up to this point, I had a functioning Azure Mobile Service with service-directed OAuth working nicely for Google. I tried to rehost the mobile service as an app service since mobile services are deprecated. I also have an HTML/JS web app that accesses my service through the MobileServiceClient JS client. This is where the fun starts.
After changing the redirect address to the appropriate app service address in the Google API manager, I get a message saying I'm successfully logged in in a new popup window: .
Clicking on "Return to Website" takes me to the address of my app service, not the app that initiated the OAuth request, and if I close this window, the MobileServiceClient throws a "cancelled" exception and I don't get my credentials.
What am I missing or what changed that I need to account for?
Thanks!
It turns out that this particular behavior happens when using an older version of the MobileServiceClient JS library. Replacing the 1.2.7 version with the 2.0.0beta version fixed this. To get the whole OAuth flow working, I also needed to add the appropriate addresses to the allowedExternalRedirectUrls node of the config/authsettings node through the Azure Resource Explorer. If there is a nicer way to do it than through the resource explorer, I don't know what it is.

How to reduce Worklight application url?

How to reduce below worklight application url to shorter form?
For ex: My application url is //hostname:ipaddress/projectName/apps/services/preview/projectNameApp/common/0/default/projectNameApp.html"
I want to set up a url which can be accessible easily over the internet. what are the settings required to get shorter url in worklight project
For ex
//hostname:portno/context path/appIndexPage.html
instead of
//hostname:ipaddress/projectName/apps/services/preview/projectNameApp/common/0/default/projectNameApp.html"
Thanks.
See the answers here and the getting started module here.
This is not the URL of your all. This is the URL of the app PREVIEW. Moreover, this is preview of common environment. If you're targeting mobile/desktop web environment - add it to your project and then use WL console to generate short link. - Anton
If you are aiming to use the Mobile Web environment, meaning you take the public URL of the app from Worklight Console and place it in your mobile web site for users to access, there is the option to use bit.ly to shorten the URL; you will first need to create an account at http://bit.ly. - Idan Adar