0

I want to setup an Android and iOS App that calls my WP site via WebView. Somehow, i wasn't able to find the best way to do this via Google. First I was thinking about putting some Code in my functions.php that detects if I am a WebView App Visitor and then deliver another Theme. Then I thought about using the Multisite Function for this, but i believe this is not a good Idea since I am not really using two "different" Websites, for which this Function is, I just need different themes delivered.

So, what would the best Practice for this? Detect if the user is surfing with WebView and then change the Theme (which WP Function can do that?).

Note: I am trying to not use any Theme-Switcher Plugins for this since I want to keep the Plugin Bloat as small as possible.

Thanks!

UPDATE: Since I think my Question was not well written... The Website already is responsive for mobile users that visit the site with their regular mobile phone browser. My Goal is to to deliver a completely different theme for People that use a App that I am going to develop, since the App is going to work different than the regular website but still needs to grab the WP Posts - WebView App detection will be made via User Agent or similar.

2 Answers 2

0

hmm this is called responsive web design. Being responsive doesn't mean the UI has to be 100% the same.

Have your JS detect that you are in webview, maybe via user agent, and then set some appropriate class on the body element. design your webview design around that class.

3
  • Sorry, but this is not the solution. The Website is already responsive, I just want to deliver a complete different Layout for the WebView App instead of coding a more complex App that fetches all the Data from WordPress via JSON f.e..
    – pukka
    Commented Nov 17, 2015 at 14:13
  • You should be sorry, as this is probably the best advice you will get. It is always amazing how people come here to ask the experts for advice and then end up saying "I know better then you". If you know better why did you ask in the first place? Commented Nov 17, 2015 at 14:47
  • Maybe I should have stated in the first place that the Website already is responsive, but I did so in my Reply. I also stated that I need this "for WebView Apps", not for mobile devices in general and thought this is enough information to help me find a Solution for what I exactly asked for. I thought it was nice of you too try and explain to me, what Responsive Websites are for, but I already know. My reply was ment to guide you into the right direction, since you misunderstood. But your reply sounds like a kid thats pissed because the answer was wrong! Anyway.... thanks for trying !
    – pukka
    Commented Nov 17, 2015 at 15:37
0

My Solution now was:

1) Made my App send Custom HTTP Headers 2) Coded myself a WP Plugin that searches for these Headers with every called URL and then deliver another theme with two simple WP Filters.

With this Solution I did not had to use the Multisite feature, no Subdomain, no SEO Problems (so Far!), and of course no 10k$ App needed to make it look very nice!

I hope this is a little help for anybody who is searching for this.

3
  • so you decided to give up on the idea of doing any type of caching. Commented Dec 1, 2015 at 14:21
  • Hello again :) Since I did not find a better solution for it yet, yes, I am not caching anything before the script found out which layout to deliver. I am still open for a better solution.
    – pukka
    Commented Dec 2, 2015 at 16:10
  • can you provide some coding samples you did to achieve this ? it will be really helpful for other needful persons....
    – Dr M L M J
    Commented Apr 19, 2022 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.