문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top