Logan Gallois
Logan Gallois

Reputation: 622

Where is record device token?

I am trying to send Push Notification to all my test flight users. However, i don't know how i have to proceed. I followed the raywenderlich tutorial (here)

in the php file :

// Put your device token here (without spaces):
$deviceToken = 'e606c132727582dab8b280a01cb3c6498141f1e8b4ce61f66b47xxxxxxxxxxxx';

// Put your private key's passphrase here:
$passphrase = 'xxxxxxxx';

// Put your alert message here:
$message = 'My first push notification!';

you need to put the device token. Then how i can get all device token register to put in this file ? I would like try this :

$deviceToken = getAllToken()

with getAllToken() return an array with all deviceToken registered with testFlight

I hope it's clear :)

Thanks !

Upvotes: 1

Views: 125

Answers (1)

tomsoft
tomsoft

Reputation: 4577

Test flight won't help you in this. You need to record the deviceToken obtained through "didRegisterForRemoteNotification" and send it to the server. Here is an example in Swift (don't forget to remove some specific characters in the device token lik I've done).

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
  // This method will be called everytime you open the app
  NSLog("Device token:\(deviceToken)")
  filteredDeviceToken=deviceToken.description.filter { $0 != Character(" ") } .filter { $0 != Character("<") }.filter { $0 != Character(">") }
  sendToServer(filteredDeviceToken);
}

Of course, it's the "sendToServer" that will gives this information to your backend, and this is dependent of you.

You can also use existing services, like pushBot, parse, and others to take care of this for you: just add their lib and then you can send a push to all registered device

Upvotes: 1

Related Questions