如何通过单击电子邮件中发送的超链接将用户重定向到移动应用程序或网站?是否需要在服务器端使用 PHP 进行处理? [英] How to redirect the user to a mobile app or a website on click of a hyperlink sent in an email? Should it need to be handled on server-side using PHP?

查看:23
本文介绍了如何通过单击电子邮件中发送的超链接将用户重定向到移动应用程序或网站?是否需要在服务器端使用 PHP 进行处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 PHPFox 开发的网站,并且运行良好.现在,iOS 开发团队在 iOS 中创建了一个移动应用程序,用于与网站相同的功能.用户可以使用此应用程序执行他/她可以在网站上执行的所有操作.换句话说,我们可以说这个应用程序是现有网站的复制品.应用程序开发的唯一限制是流程和功能应与网站相同.应用程序和现有运行的网站之间不应存在任何功能差异.

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 代码库中存在的相同功能.我正在通过使用 Slim 框架开发的 REST API 向 iOS 团队提供这些功能.在这些 API 中,我接受来自应用程序的 JSON 格式的请求,对其进行解码,通过传递所需的请求参数从 PHPFox 代码库调用所需的函数,从函数获取响应,将其转换为 JSON 格式并将其发送回到移动应用.

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.

现在,让我们专注于我面临的问题.

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.

当该特定用户单击收到的邮件中的超链接时,它会被重定向到仅网站.它不会重定向到应用程序.

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?

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

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?

我研究了这个问题的解决方案.我开始知道 Bitly 可以完成这项工作,但不知道如何做.

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

这个需求是iOS团队在他们在互联网上找到的这篇超链接文章.也请参考这个.

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)无关,我是否应该使用 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 团队)需要向 iOS 应用程序添加 URL 方案以实现深层链接.然后你需要一个网站来检查这个 URL 方案(以及 iOS 应用程序)是否在设备上可用.如果是,那么您转发到应用程序,如果不是,则转发到网站.然后,您在电子邮件中嵌入支票网站的链接.

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.

有些服务可以帮助您完成整个设置.我知道一个是 https://branch.io,但我相信还有更多.

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.

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

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

来自该链接:要启用深层链接,请转到 Xcode 项目中的信息选项卡.在 URL 类型部分,单击 + 按钮,然后添加标识符和 URL 方案.确保标识符和您选择的 URL 方案是唯一的.请记下您输入的 URL 方案,因为这是 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."

要遵循更多步骤,因此请务必阅读全文.

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

为 iOS 和 Web 创建链接:

Create a link for iOS and Web:

创建链接要么启动 iOS 应用,要么重定向到应用商店

是是否可以为 iPhone 应用程序(例如 YouTube 和地图)注册基于 http+域的 URL 方案?

您希望重定向到您的网页,而不是重定向到 AppStore.

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

这篇关于如何通过单击电子邮件中发送的超链接将用户重定向到移动应用程序或网站?是否需要在服务器端使用 PHP 进行处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆