那些我们开发依赖电话号码的应用时的错误假设

… and tips on how to use libphonenumber.

Given how ubiquitous phone numbers are and how long they’ve been around, it’s surprising how many false assumptions programmers continue to make about them.

1.An individual has a phone numberSome people do not own phones, or do not wish to provide you with their telephone number when asked. Do not require a user to provide a phone number unless it is essential, and whenever possible try and provide a fallback to accommodate these users.2.An individual has only one phone numberObviously, this isn’t necessarily true.3.A phone number uniquely identifies an individualIt wasn’t even that long ago that mobile phones didn’t exist, and it was common for an entire household to share one fixed-line telephone number. In some parts of the world, this is still true, and relatives (or even friends) share a single phone number. Many phone services (especially for businesses) allow multiple inbound calls to or outbound calls from the same phone number.4.Phone numbers cannot be re-usedOld phone numbers are recycled and get reassigned to other people.5.Phone numbers that are valid today will always be valid. Phone numbers of a certain type today (e.g., mobile) will never be reassigned to another type.A phone number which connects today may be disconnected tomorrow. A number which is free to call today may cost money to call tomorrow. The phone company may decide to expand the range of available phone numbers by inserting a digit into an existing number.Tip: Don’t store properties for a phone number such as validity or type. Check this information again from the library when you need it.6.Each country calling code corresponds to exactly one countryThe USA, Canada, and several Caribbean islands share the country calling code +1. Russia and Kazakhstan share +7. These are not the only examples<img src="https://link.juejin.cn/?target=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FToll-free_telephone_number%23Universal_International_Freephone_Service “https://en.wikipedia.org/wiki/Toll-free_telephone_number#Universal_International_Freephone_Service”). Some may be dialable only if the caller is a subscriber to a particular telecom company.9.You can send a text message to any phone numberA lot of people still only have a fixed-line telephone, which typically cannot send or receive text messages.Tip: Whenever possible, try and accommodate these users by calling them with a voice message or voice prompts. Alternatively, if your service requires sending text messages, verify that the number can receive text messages after the user prov

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值