trigger.io programmatically set orientation

2019-07-11 05:01发布

问题:

Is there a way to programmatically set orientation? The issue I am having is a horrid looking launchimage while the app is loading in landscape orientation. This is true for both iOS and Android. My launch image has a white background and when holding (or simulating) the device in landscape one can see the black background filler.

Maybe I can restrict the orientation to portrait in the config... and then after launch is complete... then allow (programmatically set) for both landscape and portrait? Or maybe allow me to set the launchimage filler color to something other than black (which looks fine using the default trigger.io launchimage because it has a black background)? My current settings are:

    "launchimage": {
    "iphone": "img/320x480.png",
    "iphone-retina": "img/640x960.png",
    "ipad": "img/768x1004.png",
    "ipad-landscape": "img/1024x748.png",
    "android": "img/640x960.png",
    "android-landscape": "img/1024x748.png"
    },

The launch image (while holding the device in landscape) looks similar to this image

回答1:

There's currently no Forge API to programmatically set orientation, but we've been asked about it before and have a ticket in our backlog, which we've bumped up.

I'll report back here when the API is available.

Update: this is now available in our v1.4.13 platform version: http://docs.trigger.io/en/v1.4/release-notes.html#v1-4-13



回答2:

It appears than forcing landscape as only available orientation in App config conflicts with display.orientation.forceLandscape() statement, resulting in a portrait app (even if the success callback is triggered)

[DEBUG] Native call "display.orientation_forceLandscape" with task.params: {}

[DEBUG] Returning event: {"event":"internal.orientationChange","params":{"orientation":"portrait"}}

If I omit "display.orientation.forceLandscape()", all is working fine.

Hope this helps



回答3:

The reason for this seems to be the down-scaling of images due to the devices pixel ratio / pixel density.

Example: The Samsung Galaxy Nexus has a pixel ratio of 2 (Source). If you want to have a full width launch image in landscape mode (1280 x 720 px), you'd need an image with at least 2560 pixel in width.

By the way: as of platform version v1.4.21 you can change the background color of Android launch images in the config.



标签: trigger.io