PHP Api iOS - Launch app from PHP code? [duplicate]

大兔子大兔子 提交于 2020-07-08 03:20:43

问题


I was trying to create some web app using Framework 7. Everything's fine, but i'd like to be able to call an app from the Home Screen (for example, the Store or the News app).

I know that some APIs are published by Apple Inc, but I can't find a way to call an app from my PHP code.

The Web app is created to run in Safari.

I tried something like:

<script type="text/javascript" charset="utf-8">

                window.location = "myapp://iMessage";

    </script>

But it doesn't seem to be able to launch the app.


回答1:


Before iOS 9

In order to open another app in iOS you need to know what schemes it supports. Not all apps use them, so not every app is openable this way. An example scheme that opens up AppStore looks like this :

itms://itunes.apple.com/us/app/apple-store/id375380948?mt=8

This will open AppStore on "Apple Store" apps screen. You can test this also by replacing itms with https and pasting in your browser. The itms part is the scheme, and the rest are the parameters passed to the app.

Since iOS9

Apps can register to handle "generic" URLS, so a URL like http://9gag.com/gag/a1MXxR2 will be opened in 9GAG app (unless the user doesn't agree to it - he will be asked the first time he opens such a link in Safari, then it will be opened in Safari).

Note that not all apps support it yet, and there is no way (apart from asking the creators) to know if they ever will.


So to answer your question : there is no generic way to open a "random" app installed on someones phone. Especially not apps which don't support such opening via URLs (no matter whether with a custom scheme, or http(s)).

Some of the popular apps (Facebook, Twitter, Chrome, ...) publish their schemes and you can implement them, not all will do so.

Note: this all applies to non-jailbroken phones.




回答2:


There's not a general purpose way to open any app. Opening a specific app requires that:

  1. that app has registered to respond to a specific URL scheme (e.g. instagram://)
  2. you know what the URL scheme is. Sometimes an app's URL scheme isn't publicly available.

I think "myapp://" scheme you're using was someone's example but doesn't apply to all apps.



来源:https://stackoverflow.com/questions/34750667/php-api-ios-launch-app-from-php-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!