Obtaining a device token

I’m having trouble obtaining the device token for sending push notifications. Is there a simple way to get it, for example, using an MIT app extension or by other means?