Update: I just installed the app on another new iOS device and got the "token mismatch" error again. After some hours of testing I could not only solve the issue, but now can even reproduce it:
Remember: On my first iOS device I could only use phonenumber-registration after I had changed from dev to production profile in apple developer portal. When I tapped my register-button the first time after this change, I got the "token mismatch" error again, but after tapping a second time after a couple of seconds, it worked for the first time. I could then even go back to development profile and it worked.
Now, still in development-profile, I installed my app on a new device: Token mismatch. So I again changed everything to production mode, installed it, and again got the "token mismatch" error on first tap, but a successfull registration after second tap on my button.
Once this works, it does work even after I reinstall the app. But as soon as I factory-reset the iphone and install the app on this fresh device, I get the "token mismatch" error again for the first tap and it takes a second tap after a couple of seconds to make it work.
So, these observations make me conclude that
stores the token somewhere independent from the app (since deleting and reinstalling the app allows registration right away), but gets - of course - lost when iphone is factoryreset and of course is not yet there on a new device. In these two cases it is necessary to call
twice: The first time to receive the token through
local function onNotification(event)
if event.type == "remoteRegistration" then
-- Set up a notification listener.
even though at this time a "token mismatch" error occurs, and then a second time to use the token.
Scott: Does this make sense to you? Can you confirm my guesses or am I wrong in my conclusions? Most important question though: How can I get the token before actually using it in "sendVerificationCode(phoneNumber,listener)" - function?
Would appreciate any clarification here