c0rrupt / FreegliAPNSBundle

APNs component's bundle for Symfony2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Freegli APNs Bundle

Freegli APNs Bundle intends to provide an easy to use Bundle for the Apple Push Notification Service (APNs).

WARNING: WIP

How To

Requirements

Configuration

You can include this code in your deps file.

[FreegliAPNSBundle]
    git=git://github.com/Freegli/FreegliAPNSBundle.git
    target=bundles/Freegli/Bundle/APNSBundle

[FreegliAPNs]
    git=git://github.com/Freegli/APNs.git

You need to specify your certificate path into parameters. The following example use certs subdirectory including dev_apns_cert.pem and prod_apns_cert.pem, without passphrase.

[parameters]
    freegli.apns.connection_factory.certificat_path = %kernel.root_dir%/../certs/%kernel.environment%_apns_cert.pem
    freegli.apns.connection_factory.certificat_passphrase = 

Sample code

TestController.php provide a sample code.

Tokens

Binary tokens length is 32. Freegli APNs component require an hexadecimal string representation. Its length is 64 (32 * 2).

Here is a sample code to obtain hexadecimal representation of NSData in your Objective-C project.

@implementation NSData (HexadecimalRepresentation)

- (NSString *)hexadecimalRepresentation {
    static const char hexValues[] = "0123456789abcdef";
    const size_t len = [self length];
    const unsigned char *data = [self bytes];
    char *buffer = (char *)calloc(len * 2 + 1, sizeof(char));
    char *hex = buffer;
    NSString *hexBytes = nil;

    for (int i = 0; i < len; i++) {
        const unsigned char c = data[i];
        *hex++ = hexValues[(c >> 4) & 0xF];
        *hex++ = hexValues[(c ) & 0xF];
    }

    hexBytes = [NSString stringWithUTF8String:buffer];

    free(buffer);

    return hexBytes;
}

@end

Resources

About

APNs component's bundle for Symfony2


Languages

Language:PHP 100.0%