当前,我有一个GET
方法,当用户离线注销时,该方法取消注册推送通知。我将用户的设备令牌和API密钥发送到后端,这将注销用户并禁用推送通知。这很好用,但是有一个问题。如果用户离线注销,则将无法使用。
我想出的唯一解决方案是保存API密钥和设备令牌,然后等到用户重新联机。然后,我将发送API请求。不知道这种解决方案有多好,但是我想出的唯一解决方案可以工作。
编辑:我最大的担心是脱机注销时注销推送通知,而我在StackOverflow上还没有谈论过。是的,我可以在用户注销时注销注册推送通知,但在用户离线时不能注销。
编辑2:通过注销,我的意思是让服务器知道不发送推送通知。
答案 0 :(得分:0)
除了您在问题中所描述的以外,我看不到其他任何方式。我还要做的就是叫// favoriteAddrFamily returns the appropriate address family for the
// given network, laddr, raddr and mode.
//
// If mode indicates "listen" and laddr is a wildcard, we assume that
// the user wants to make a passive-open connection with a wildcard
// address family, both AF_INET and AF_INET6, and a wildcard address
// like the following:
//
// - A listen for a wildcard communication domain, "tcp" or
// "udp", with a wildcard address: If the platform supports
// both IPv6 and IPv4-mapped IPv6 communication capabilities,
// or does not support IPv4, we use a dual stack, AF_INET6 and
// IPV6_V6ONLY=0, wildcard address listen. The dual stack
// wildcard address listen may fall back to an IPv6-only,
// AF_INET6 and IPV6_V6ONLY=1, wildcard address listen.
// Otherwise we prefer an IPv4-only, AF_INET, wildcard address
// listen.
//
// - A listen for a wildcard communication domain, "tcp" or
// "udp", with an IPv4 wildcard address: same as above.
//
// - A listen for a wildcard communication domain, "tcp" or
// "udp", with an IPv6 wildcard address: same as above.
//
// - A listen for an IPv4 communication domain, "tcp4" or "udp4",
// with an IPv4 wildcard address: We use an IPv4-only, AF_INET,
// wildcard address listen.
//
// - A listen for an IPv6 communication domain, "tcp6" or "udp6",
// with an IPv6 wildcard address: We use an IPv6-only, AF_INET6
// and IPV6_V6ONLY=1, wildcard address listen.
//
// Otherwise guess: If the addresses are IPv4 then returns AF_INET,
// or else returns AF_INET6. It also returns a boolean value what
// designates IPV6_V6ONLY option.
//
// Note that the latest DragonFly BSD and OpenBSD kernels allow
// neither "net.inet6.ip6.v6only=1" change nor IPPROTO_IPV6 level
// IPV6_V6ONLY socket option setting.
。这将停止向已注销用户的手机发送推送通知,但会不提醒您的服务器注销。 Apple在其文档中指出,调用此方法here后,您可以重新注册通知。
当另一个用户登录时,您重新注册推送通知并将设备令牌链接到他们的帐户。