如何将用户重定向到移动应用程序或网站,点击电子邮件中的超链接?是否需要在服务器端使用PHP进行处理?

时间:2022-04-22 15:34:28

I've a website which is already developed using PHPFox and it's working fine. Now, iOS development team has created a mobile app in iOS for the same functionality as of the website. User can do all the operations using this app which he/she can do on a website. In other words we can say this app is a replica of the existing website. The only restriction in development of app is that the flow and functionality should be same as of the website. There should not be any functionality discrepancy between the app and the existing running website.

我有一个使用PHPFox开发的网站,它运行良好。现在,iOS开发团队已经在iOS中创建了一个与网站功能相同的移动应用。用户可以在网站上使用这个app进行所有操作。换句话说,我们可以说这个应用程序是现有网站的复制品。app开发中唯一的限制是流程和功能应该与网站相同。应用程序与现有运行网站之间不应有任何功能上的差异。

For this app, they are using the same functions present into the website's PHPFox code base. I'm making the iOS team these functions available by means of REST APIs developed using Slim framework. In these APIs I'm accepting the request in JSON format from the app, decode it, call the required function from PHPFox code base by passing the required request parameters, get the response from the function, convert it into JSON format and send it back to the mobile app.

对于这个应用程序,他们使用的功能与网站的PHPFox代码库相同。我通过使用Slim框架开发的REST api使iOS团队可以使用这些功能。在这些api中,我从应用程序中接受JSON格式的请求,解码它,通过传递所需的请求参数,从PHPFox代码库调用所需的函数,从函数中获取响应,将其转换成JSON格式并将其发送回移动应用程序。

Now, let's focus on the issue I'm facing.

现在,让我们关注我所面临的问题。

In both the scenarios(website and app) for some functionalities like new user account activation link, resend account activation link, reset existing user's password if he/she forgets password, etc. an email is sent to the concerned user. This email contains the relevant hyperlink. When user clicks on this hyperlink sent into the email, it always redirects to the respective web page on website.

在两种情况下(网站和app)都有一些功能,比如新用户账号激活链接、重新发送账号激活链接、忘记密码重置现有用户密码等。此邮件包含相关的超链接。当用户点击发送到电子邮件的超链接时,它总是重定向到网站上相应的网页。

When that specific user clicks on the hyperlink present into the received mail it gets redirected to the website only. It doesn't redirect to the app.

当特定的用户点击出现在收到的邮件中的超链接时,它只会被重定向到网站。它不会重定向到应用程序。

My requirement is if user has opened the mail on to the device which also has installed/runs the mobile app and clicks on a hyperlink in a mail he/she should redirect to the specific page of mobile app not the website.

我的要求是,如果用户已经打开了该设备的邮件,该设备还安装/运行了移动应用程序,并在邮件中点击一个超链接,他/她应该重定向到移动应用程序的特定页面,而不是网站。

And suppose if user has opened a mail on a computer, laptop or a device where the app is not installed he/she should redirect to the website.

假设用户在未安装应用程序的电脑、笔记本或设备上打开了邮件,他/她应该重定向到该网站。

How should I achieve this?

我应该如何做到这一点?

One more thing to be noted here is the redirection path(value of the href attribute) of the link to be send into the mail is generated into the website's PHPFox code only. So, if I need to make change into the logic to achieve this new functionality how should I do without changing the system flow on app and website? Or should I write a new function for it in order to not change the existing code of PHPFox?

这里还需要注意的一点是要发送到邮件的链接的重定向路径(href属性的值)仅生成到网站的PHPFox代码中。那么,如果我需要对实现这个新功能的逻辑进行修改,我该如何做才能不改变应用程序和网站上的系统流程呢?或者我应该为它编写一个新的函数,以不改变PHPFox的现有代码?

I researched about the solution to this issue. I came to know about Bitly that could do this job but couldn't understand how.

我研究了解决这个问题的办法。我开始了解到,Bitly可以做这个工作,但我不知道怎么做。

This requirement is raised by iOS team to me (PHP team) on the basis of this hyperlink article they have found on the internet. Please refer this also.

这一要求是由iOS团队(PHP团队)根据他们在互联网上找到的超链接文章提出的。请参考这也。

So, my straight-forward question is since this article is about iOS coding and it nothing has to do with server-side coding (i.e. PHP) should I have to do anything on server-side using PHP to achieve this functionality?

因此,我直接的问题是,既然这篇文章是关于iOS编码的,它与服务器端编码(即PHP)没有任何关系,我是否应该使用PHP在服务器端实现这个功能?

4 个解决方案

#1


3  

You (or your iOS-team) need to add an URL scheme to the iOS app to make deep linking possible. Then you need a website which checks if this URL scheme (and therefore the iOS app) is available on the device. If yes, then you forward to the app, if no you forward to the website. Then you embed the link to the check website in your emails.

您(或您的iOS团队)需要向iOS应用程序添加一个URL方案,以使深度链接成为可能。然后你需要一个网站来检查这个URL方案(以及iOS应用程序)在设备上是否可用。如果是,那么你就转发给应用,如果不是,你就转发给网站。然后在你的电子邮件中嵌入到check网站的链接。

There are services, which can help you with the whole setup. One I know is https://branch.io but I'm sure there are more out there.

有一些服务可以帮助您完成整个设置。我知道的一个是https://branch。是的,但我肯定还有更多。

Edit:

编辑:

Deep Linking in iOS: http://blog.originate.com/blog/2014/04/22/deeplinking-in-ios/

iOS中的深度链接:http://blog.originate.com/blog/04/22/deeplink -in-ios/

From that link: "To enable deep linking, go to the Info tab in the Xcode project. In the URL Types section, click on the + button, and then add an identifier and a URL scheme. Ensure that the identifier and URL scheme you select are unique. Take note of the URL scheme you enter, as this is how iOS knows to open a link in your app."

从该链接:“要启用深度链接,请转到Xcode项目中的Info选项卡。”在URL类型部分,单击+按钮,然后添加一个标识符和一个URL方案。确保所选择的标识符和URL方案是唯一的。注意你输入的URL格式,这是iOS如何在你的应用中打开链接的。

There are more steps to follow, so make sure to read the whole thing.

接下来还有更多的步骤,所以一定要阅读整个内容。

Create a link for iOS and Web:

为iOS和Web创建链接:

Create a link that either launches iOS app, or redirects to app store

创建一个可以启动iOS应用程序或重定向到app store的链接

and

Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?

是否有可能为iPhone应用程序注册一个基于http+域名的URL方案,比如YouTube和Maps?

instead of redirecting to the AppStore, you'd like to redirect to your webpage.

与其重定向到AppStore,不如重定向到你的网页。

#2


1  

You do not have to do anything. Ask your iOS developers to read about URL Schemes which seems to have been explained in the link you mentioned based on which the iOS team has contacted you. That link shows how you can make your app capable of being launched from another place(app-in your case the mail app). The reason why the email takes the user to the website and not the app is because the hyperlink mentions your web link and says nothing about the app.

你什么都不用做。请iOS开发人员阅读关于URL方案的内容,这似乎已经在您提到的链接中得到了解释,基于这个链接,iOS团队已经联系了您。这个链接显示了你如何让你的应用程序能够从另一个地方(在你的邮件应用程序)中启动。电子邮件将用户带到网站而不是应用程序的原因是,超链接提到了你的网络链接,并没有提到这个应用。

Basically similar to how your website has a link of the form sayhttp://youwebsite.com/, the app also has a link of the for yourapp:// which works on the device once the iOS app has integrated URL scheme. So you need to mention this URL in the email hyperlink.

基本上类似于你的网站有一个表单的链接sayhttp://youwebsite.com/,这个应用还有一个你的应用的链接://,一旦iOS应用有了集成的URL方案,这个链接就可以在设备上运行。所以你需要在邮件超链接中提到这个URL。

Refer to this answer which might help you to setup the mail link.

请参考这个答案,它可以帮助您设置邮件链接。

So to sum up,

所以综上所述,

  1. You need to do nothing
  2. 你什么都不用做
  3. iOS team needs to integrate URL Scheme
  4. iOS团队需要整合URL方案
  5. The place from where the email is generated make sure the link is updated appropriately
  6. 电子邮件生成的地方确保链接被适当地更新。

P.S.: Use the link above for figuring out how the link is to work, haven't explained it here for 2 reasons,

注::使用上面的链接来弄清楚这个链接是如何工作的,并没有在这里解释两个原因,

a) Its beyond the scope of the questions, you needed to know if you need to do any change as PHP developer, So Answer is NO.

a)这超出了问题的范围,您需要知道作为PHP开发人员是否需要做任何更改,所以答案是否定的。

b) It is already addressed in this answer

b)答案中已经说明了这一点

#3


1  

Using javascript, you can have a landing page to tunnel the users:

使用javascript,您可以有一个着陆页面来隧道用户:

You can redirect the user to an app scheme using the following:

您可以使用以下方法将用户重定向到应用程序方案:

 document.location="myApp://myUrl";

If the browser does not find the uri scheme, you can use a setTimeout to redirect the user to your webpage

如果浏览器没有找到uri方案,您可以使用setTimeout将用户重定向到您的网页。

setTimeout(function() {
   document.location="/path/inside/website.html";
}, 100);

Another good solution would be to test the existence of the url schema using an iframe on a small test file, and redirect the current page if the iframe can be loaded

另一个好的解决方案是使用一个小测试文件上的iframe测试url模式的存在性,如果可以加载iframe,则重定向当前页面

<iframe id="ifrm" src="" style="display:none"></iframe>
<script>
window.frames['ifrm'].onload = function() {
   document.location="myApp://myUrl";
};
window.frames['ifrm'].src = "myApp://myUrl/ok.txt";
</script>

#4


1  

As my Understanding the solution is simple.

我的理解很简单。

Whenever user request for forgot password or create new account..etc. you have to identify that user send request from iPhone or Website, if the User send request from website you have to pass activation link for web-page else you have to send link for app like this "itms-apps://itunes.apple.com/app/idyourappID", according to me for identified this PHP team have to get one more parameters from development team which is used to identify the device like 'web' or 'mobile' so that your problem will be solve.

每当用户要求忘记密码或创建新帐户等。你必须确定从iPhone用户发送请求或网站,如果用户从网站发送请求你必须通过激活其他网页的链接你必须发送链接应用程序这样的“itms-apps:/ /itunes.apple.com/app/idyourappID”,据我发现这个PHP团队从开发团队需要一个参数用于确定设备像“网络”或“移动”,这样你的问题就会解决。

Hope this will help you.

希望这能对你有所帮助。

#1


3  

You (or your iOS-team) need to add an URL scheme to the iOS app to make deep linking possible. Then you need a website which checks if this URL scheme (and therefore the iOS app) is available on the device. If yes, then you forward to the app, if no you forward to the website. Then you embed the link to the check website in your emails.

您(或您的iOS团队)需要向iOS应用程序添加一个URL方案,以使深度链接成为可能。然后你需要一个网站来检查这个URL方案(以及iOS应用程序)在设备上是否可用。如果是,那么你就转发给应用,如果不是,你就转发给网站。然后在你的电子邮件中嵌入到check网站的链接。

There are services, which can help you with the whole setup. One I know is https://branch.io but I'm sure there are more out there.

有一些服务可以帮助您完成整个设置。我知道的一个是https://branch。是的,但我肯定还有更多。

Edit:

编辑:

Deep Linking in iOS: http://blog.originate.com/blog/2014/04/22/deeplinking-in-ios/

iOS中的深度链接:http://blog.originate.com/blog/04/22/deeplink -in-ios/

From that link: "To enable deep linking, go to the Info tab in the Xcode project. In the URL Types section, click on the + button, and then add an identifier and a URL scheme. Ensure that the identifier and URL scheme you select are unique. Take note of the URL scheme you enter, as this is how iOS knows to open a link in your app."

从该链接:“要启用深度链接,请转到Xcode项目中的Info选项卡。”在URL类型部分,单击+按钮,然后添加一个标识符和一个URL方案。确保所选择的标识符和URL方案是唯一的。注意你输入的URL格式,这是iOS如何在你的应用中打开链接的。

There are more steps to follow, so make sure to read the whole thing.

接下来还有更多的步骤,所以一定要阅读整个内容。

Create a link for iOS and Web:

为iOS和Web创建链接:

Create a link that either launches iOS app, or redirects to app store

创建一个可以启动iOS应用程序或重定向到app store的链接

and

Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?

是否有可能为iPhone应用程序注册一个基于http+域名的URL方案,比如YouTube和Maps?

instead of redirecting to the AppStore, you'd like to redirect to your webpage.

与其重定向到AppStore,不如重定向到你的网页。

#2


1  

You do not have to do anything. Ask your iOS developers to read about URL Schemes which seems to have been explained in the link you mentioned based on which the iOS team has contacted you. That link shows how you can make your app capable of being launched from another place(app-in your case the mail app). The reason why the email takes the user to the website and not the app is because the hyperlink mentions your web link and says nothing about the app.

你什么都不用做。请iOS开发人员阅读关于URL方案的内容,这似乎已经在您提到的链接中得到了解释,基于这个链接,iOS团队已经联系了您。这个链接显示了你如何让你的应用程序能够从另一个地方(在你的邮件应用程序)中启动。电子邮件将用户带到网站而不是应用程序的原因是,超链接提到了你的网络链接,并没有提到这个应用。

Basically similar to how your website has a link of the form sayhttp://youwebsite.com/, the app also has a link of the for yourapp:// which works on the device once the iOS app has integrated URL scheme. So you need to mention this URL in the email hyperlink.

基本上类似于你的网站有一个表单的链接sayhttp://youwebsite.com/,这个应用还有一个你的应用的链接://,一旦iOS应用有了集成的URL方案,这个链接就可以在设备上运行。所以你需要在邮件超链接中提到这个URL。

Refer to this answer which might help you to setup the mail link.

请参考这个答案,它可以帮助您设置邮件链接。

So to sum up,

所以综上所述,

  1. You need to do nothing
  2. 你什么都不用做
  3. iOS team needs to integrate URL Scheme
  4. iOS团队需要整合URL方案
  5. The place from where the email is generated make sure the link is updated appropriately
  6. 电子邮件生成的地方确保链接被适当地更新。

P.S.: Use the link above for figuring out how the link is to work, haven't explained it here for 2 reasons,

注::使用上面的链接来弄清楚这个链接是如何工作的,并没有在这里解释两个原因,

a) Its beyond the scope of the questions, you needed to know if you need to do any change as PHP developer, So Answer is NO.

a)这超出了问题的范围,您需要知道作为PHP开发人员是否需要做任何更改,所以答案是否定的。

b) It is already addressed in this answer

b)答案中已经说明了这一点

#3


1  

Using javascript, you can have a landing page to tunnel the users:

使用javascript,您可以有一个着陆页面来隧道用户:

You can redirect the user to an app scheme using the following:

您可以使用以下方法将用户重定向到应用程序方案:

 document.location="myApp://myUrl";

If the browser does not find the uri scheme, you can use a setTimeout to redirect the user to your webpage

如果浏览器没有找到uri方案,您可以使用setTimeout将用户重定向到您的网页。

setTimeout(function() {
   document.location="/path/inside/website.html";
}, 100);

Another good solution would be to test the existence of the url schema using an iframe on a small test file, and redirect the current page if the iframe can be loaded

另一个好的解决方案是使用一个小测试文件上的iframe测试url模式的存在性,如果可以加载iframe,则重定向当前页面

<iframe id="ifrm" src="" style="display:none"></iframe>
<script>
window.frames['ifrm'].onload = function() {
   document.location="myApp://myUrl";
};
window.frames['ifrm'].src = "myApp://myUrl/ok.txt";
</script>

#4


1  

As my Understanding the solution is simple.

我的理解很简单。

Whenever user request for forgot password or create new account..etc. you have to identify that user send request from iPhone or Website, if the User send request from website you have to pass activation link for web-page else you have to send link for app like this "itms-apps://itunes.apple.com/app/idyourappID", according to me for identified this PHP team have to get one more parameters from development team which is used to identify the device like 'web' or 'mobile' so that your problem will be solve.

每当用户要求忘记密码或创建新帐户等。你必须确定从iPhone用户发送请求或网站,如果用户从网站发送请求你必须通过激活其他网页的链接你必须发送链接应用程序这样的“itms-apps:/ /itunes.apple.com/app/idyourappID”,据我发现这个PHP团队从开发团队需要一个参数用于确定设备像“网络”或“移动”,这样你的问题就会解决。

Hope this will help you.

希望这能对你有所帮助。