Pergunta

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.

Foi útil?

Solução

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()],
});

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top