Autista_z
Autista_z

Reputation: 2541

Sending push notification to iOS device

I'm trying to send push notification to the device, on which I have my created pkpass. Device is successfully registered for automatic updates, I have its token.

For making push to APNS I'm using package "daim2k5/laravel-push-notification". I'm using Laravel 5.2, for which it is not very much packages, for 5.3 is more.

But when I'm trying to push, I always get Adapter APNS does not support 2a984ecb2a947786dc4479d25109a172 token's device (token is in this format, its not real token, just example)

$devices = \PushNotification::DeviceCollection(array(
        \PushNotification::Device('2a984ecb2a947786dc4479d25109a172', array('badge' => 1))
    ));

$r = \PushNotification::app([
        'environment' =>'production',
        'certificate' =>'awdrca.pem',
        'passPhrase'  =>'password',
        'service'     =>'apns'
    ])->to($devices) ->send('Test');

Is the token I have really invalid? Or is there error some where else?

Upvotes: 1

Views: 2527

Answers (1)

ranatouqeer
ranatouqeer

Reputation: 58

Make sure you are getting correct formatted device token from the iOS device here is an example to get the right supported format for the device token.

NSString * token = [NSString stringWithFormat:@"%@", deviceToken];
    //Format token as you need:
    token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
    token = [token stringByReplacingOccurrencesOfString:@">" withString:@""];
    token = [token stringByReplacingOccurrencesOfString:@"<" withString:@""];
    NSLog(@"%@", token);

Secondly try using davibennun laravel-push-notification package it is simple and easy to configure for both iOS and Android. https://github.com/davibennun/laravel-push-notification

Upvotes: 1

Related Questions