Unify getDeviceTokens() logic.