简体   繁体   English

在基于Web的应用程序中,如何在基于Web的应用程序URL的末尾调用用户的IMEI / UDID?

[英]In web-based apps, how do I call a user's IMEI / UDID to the end of my web-based app's URL?

I'm making a pair of website-based apps for both Android and iOS interfaces, and I'm struggling with a part of it. 我正在为Android和iOS界面制作一对基于网站的应用程序,而我正在努力解决其中的一部分。 Perhaps you guys could help me out! 也许你们可以帮帮我!

I'm using Android Studio and Xcode, and launching the website through WebKit and WK WebView respectively. 我正在使用Android Studio和Xcode,并分别通过WebKit和WK WebView启动网站。 It's super simple, just an app which calls a website into it directly. 它非常简单,只需一个直接将网站调用到其中的应用即可。 No external navigation, nothing but a full-page website. 没有外部导航,只有一个整页的网站。 And this part is working great! 这部分效果很好!

But I do have one problem! 但是我确实有一个问题! I don't want my users to get consistently logged out if they close the app, or after a few hours of not using it. 我不希望我的用户在关闭应用程序后或几个小时不使用它后始终退出登录。 I'd like it to stay logged in for them, or to automatically log-in when they use it. 我希望它能够为他们保持登录状态,或者在他们使用它时自动登录。

The maker of the website has given me a way to do this through the URL. 该网站的制造商为我提供了一种通过URL进行此操作的方法。

Basically, my URL currently is set up like " https://URL.com/x/y/z " and it goes to the website, and that is great, but I need to set it up to be " https://url.com/x/y/z/[insert user's IMEI or UDID here]". 基本上,当前我的URL设置为“ https://URL.com/x/y/z ”,并且它转到了网站,这很好,但是我需要将其设置为“ https:// url.com/x/y/z/ [在此处插入用户的IMEI或UDID]“。 That unique ID from their Android device will keep them logged in. I've tested it using my own device with my own IMEI and it works great, but obviously using one specific identifier for everyone will not work. 他们在Android设备上使用的唯一ID将使他们保持登录状态。我已经使用自己的设备和自己的IMEI对它进行了测试,效果很好,但显然对所有人使用一个特定的标识符将无法正常工作。 I just need it to call the specific user's IMEI or UDID into the URL, to complete it. 我只需要它来将特定用户的IMEI或UDID调用到URL中即可完成。

How should I go about this? 我应该怎么做?

I am assuming that you are talking about an Android app that visualizes a website in an activity. 我假设您正在谈论的是可在活动中可视化网站的Android应用。 On Android, you can retrieve the device's IMEI OR MEID string by calling: 在Android上,您可以通过调用以下命令来检索设备的IMEI或MEID字符串:

android.telephony.TelephonyManager.getDeviceId().

But be warned, this requires that you add a permission to your manifest: 但请注意,这要求您向清单添加权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

You should inform your users why you are requesting this permission. 您应告知您的用户您为何请求此权限。

For iOS/Xcode, you can get the device UUID via UIDevice: 对于iOS / Xcode,您可以通过UIDevice获取设备UUID:

// Swift 4
let uuid = UIDevice.current.identifierForVendor!.uuidString

If you are targeting iOS 11 or newer, Apple introduced Device Check to get a device specific token. 如果您以iOS 11或更高版本为目标,则Apple引入了Device Check设备检查)以获取设备特定的令牌。 I personally haven't used it, but it sounds like it's use case is similar to what you're looking for. 我个人没有使用过它,但是听起来它的用例与您要寻找的用例相似。

Update: From your comment, here is how'd you include it in the url string. 更新:从您的评论,这是如何将其包括在url字符串中。

let urlString = "url.com/x/y/z/" + uuid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM