获取新的 Apple 设备令牌? [英] Obtain NEW Apple device token?

查看:32
本文介绍了获取新的 Apple 设备令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,允许用户退出应用程序并根据需要以其他用户身份登录.新用户登录后,有没有办法从Apple获取新的设备令牌?有没有办法强制调用 didRegisterForRemoteNotificationsWithDeviceToken 方法?

I am creating an app that allows the user to log out of the app and log in as different user if they want to. Is there any way to obtain a new device token from Apple once the new user logs in? Is there a way to force call the didRegisterForRemoteNotificationsWithDeviceToken method?

推荐答案

不,您不能请求新的设备令牌.它们会时不时地过期,只有到那时你才会得到一个新的(或者如果你有一个不同的应用程序和不同的包 ID,令牌就会不同).

No, you can't request a new device token. They expire from time to time, and only then will you get a new one (or if you have a different app with a different bundle id, the token will be different).

创建一个函数来处理 didRegister 并从 didRegisterForRemoteNotificationsWithDeviceToken 调用它.然后在需要强制调用时使用该函数.

Create a function to handle didRegister and call that from didRegisterForRemoteNotificationsWithDeviceToken. Then use that function when you need to force the call.

由于用户正在登录,所以每次有人登录时,将带有设备令牌的信息传递给服务器,并在服务器端将用户与令牌相关联.

Since users are logging in, pass the information with the device token to the server every time someone logs in and associate the user to the token on the server side.

这篇关于获取新的 Apple 设备令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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