简体   繁体   中英

Worklight 6.1 -How to get requested environment in worklight adapter

I have four environment in worklight project which are Android , Iphone , Ipad and Windows . My doubt is how to get which environment is requesting on adapter when hitting from client.

For example if i am hitting adapter from iPhone then how will i come to know request is coming from iPhone so that i can get it on adapter side and log it in api request.

There is no built-in feature to get the current environment from an adapter, however you can still find out that information by other ways. For example:

  • Parse the User-Agent from the HTTP header
 var request = WL.Server.getClientRequest(); var userAgent = request.getHeader("User-Agent"); 

Then search for keywords such as "android", etc.

  • Or, easier in my opinion, send the environment name as a parameter to your invokeProcedure!

WL.Client.invokeProcedure({
adapter : 'sample',
procedure : 'sample',
parameters : [env: WL.Client.getEnvironment()],
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM