When will Ios VoIP PushKit token get updated - ios

My app is using both user notification token and PushKit token.
I have managed to get both the tokens and saved them in my server. However, when i uninstall and reinstall my mobile app, APN only update my user notification token but not PushKit token.
Is this the default behaviour from Apple?
I am expecting APN to update both the tokens whenever I reinstall my app.
https://developer.apple.com/forums/thread/679986
This is the link for the similar question posted by others and the response from Apple was the PushKit token should also be updated upon reinstalling the app

After so many tries on uninstalling and reinstalling the app, the Pushkit token seems to only changed when I download the new app from test flight. It is the same case for test flight build. Despite giving a different Pushkit token, it wont refresh even if i reinstall the app.
The workaround for this issue that I figured out was to append my server token to the payload of the notification and compare it with the current logged in session token.

Related

FCM/APNS integration works fine for new tokens, but not when converting old APNS tokens?

I have an FCM project sending push notifications to both iOS and Android users successfully. New iOS users subscribe and retrieve an FCM token.
I however also have a number of users on old iOS apps with direct APNS subscriptions and I tried converting one old APNS token to an FCM token and send a message using this via FCM.
I used the API described here: https://www.thepolyglotdeveloper.com/2017/06/apns-tokens-fcm-tokens-simple-http/
Sending a message using FCM to the converted token, I get the error: Auth error from APNS or Web Push Service. A stackoverflow article on this error suspects project setup issues, but can this even be the case if iOS users do get pushes with new FCM tokens?
Any hints on where this goes wrong and what else I could try out would be appreciated, I am very much in the dark here.
Found it myself eventually. I had used the wrong value for the "application" parameter in the conversion API call.

Firebase Cloud Messaging: send push notification after the app was reinstalled

Is there a way to send targeted (to a concrete device or device group) push notification with some special offers after my app was reinstalled? FCM registration token changes when user reinstalls the app, so UIDevice.identifierForVendor does.
The only option I see is to use Firebase authentication which will generate UIDs for users which are the same as long as user uses the same account (even after the app is reinstalled). The idea is to associate Firebase UID with FCM registration token for the users we want to send some special offers. When our app was reinstalled then we request Firebase UID + FCM registration token again. The token will be renewed one while UID should stay the same. It will allow us to continue sending push notifications to those who should get the special offer.
Is this workaround necessary or is there an option to continue sending push notifications after my app was reinstalled without any authentication?

Where to store my developer token for a MusicKit app?

I'm dabbling with the MusicKit API and came across this in the sample app.
Keep in mind, you should not hardcode the value of the developer token in your application. This is so that if you need to generate a new developer token you are able to without having to submit a new version of your application to the App Store.
This makes me wonder where I should store the token since it has a maximum expiry of 6 months. Is the idea that I would regenerate the token on the server and have the app periodically request a new one? Am I missing something obvious?
I don't know MusicKit but I imagine you store the token in the keychain after requesting it from a server that you control. That way the app will work without an internet connection (after the first fetch of the token). Your app can ping your server when there's a connection and ask if there's a new token.
The other option is just to store it in the app's Documents directory if it doesn't need to be secure. The main difference is that they keychain data will survive a re-install. In either case it has to come from somewhere outside the app bundle (like your server).

Sending Notifications to user while app is in background

I've done lots of research on this from Firebase to App delegate but I don't understand a lot. I'm trying to send notifications to the user when someone else has posted something in my app - like on Instagram or social media post notifications. Can someone please point me in the right direction for how to do this? Thanks a lot in advance!
Overview
If you have setup your iOS app for Firebase Cloud Messaging (FCM), when the user first opens your app, the apps talks to the google servers and generated a token specific to that device.
What is a token?
The token is like a device identifier. You use that token to tell firebase which exact device you want it to send the notification to. (The token changes on uninstalling and reinstalling the app and may even on a restore).
On the backend
Now, you have to configure your app to send that token to your backend and store it as one of the tokens for the user currently logged in. (This should happen every time they login from that device, and you should remove that token from the server when the user logs out).
Whenever you need to send out a notification, you'll have to make a POST request to the FCM server. This POST request will contain the device token and the content of the notification, along with other authorization info. Detailed instructions are provided at
Send a Notification Message

How to implement "Two factor authentication" in iOS application?

I am locking my Mac screen with my Mac app. As I enters password it needs to unlock. The password should be generated internally. So I preffered to implement it by using "Two way factor authentication". By this my iPhone app generates a token frequently as I enters the token in Mac application it has to unlock.
I found few APIs like Gauthify and Authy. But they are generating tokens on their own apps(ie.,to get token from authy we need to install authy app in our mobile).
My requirement is without installing those apps,my app need to generate the token and communicate with my Mac.
Please guide me if any one had done it. Good suggestions are appreciable.
All these apps, including Google or any other apis use two step authentication. Here they generate a token with some private key and pass that to end user via sms or mail or any other medium. This sms or mail is registered with user in application database.
There is no need to use such app if you have your same app in your MAC and your ios Device.
You just need to identify how will you pass that key.
If MAC is generating token, and you know which device is trying to connect with MAC, you can send that token in background to that ios Device and match that. If you are using socket connections, this is option for you
When user enters Token, you can make a request to server to check that token. For this you need to send token genereated on MAC to server and save it somewhere. These tokens generally expires after some time, so run cron job to delete such tokens.
The apps you described use 2nd way to authenticate.
Hope this much help you. All depends your requirements and your approach :)
Cheers

Resources