I'm developing a mobile app for both Android and iOS that will receive push notifications. I've followed the instructions in the Salesforce Mobile Push Notifications Implementation Guide and created a Connected App for each platform. I've configured push for each app, and I can successfully push using the 'Send Test Notification' link on each connected app's management page.
The documentation lists instructions for sending push notifications from Apex using
Messaging.PushNotification; the process is slightly different for iOS and Android, and you pass the connected app's name when you send the notification.
So, if I want to send a push notification to Joe User, how do I know which type of notification to send? The sample code only shows pushing an iOS notification. He could have iOS or Android. When the mobile app registers, it registers for a specific connected app; the platform knows which device(s) the user has. When you send a test push notification, you can see the most recent push registrations for that connected app and even search by name - but that object (which I suspect is named Mobile Push Service Device) does not appear to be queryable.
I suppose I could have each mobile app register something on the user record or similar, but I feel like I'd be duplicating the push registration functionality, only without all the smart bits that track when a push registration is no longer valid. Should I just try to send both types of notification to every User? Seems like a waste of resources.