dreipol / django-scarface

Send push notifications to mobile devices using Amazon SNS
MIT License
43 stars 21 forks source link

Platform principal/credential fields can't hold certificates #32

Closed marcosh72 closed 5 years ago

marcosh72 commented 5 years ago

Hi,

First of all, thank you for sharing this lib. Great stuff.

I'm not sure if I'm doing something wrong or what, but I'm trying to create a new APNS Platform with the following code:

apns_platform = Platform.objects.create(
    platform='APNS',
    application=app,
    credential=getattr(settings, 'SCARFACE_APNS_PRIVATE_KEY', ''),
    principal=getattr(settings, 'SCARFACE_APNS_CERTIFICATE', ''),
)

I'm having issues because the fields credential and principal have a max_length of 255, as defined in the models.py file, but the certificate and private key content is a lot bigger than that. If I manually modify those fields in my database, then it works fine.

Is there another way to create a platform without having to store that info in the database? Or can I make a PR to increase the max_length of those fields?

Thanks!

melbic commented 5 years ago

Hey, glad your liking it.

The way you are trying to use it is actually deprecated. It's not that well documented, I am sorry. In our projects we do not store the credentials in the django app anymore, but directly in SNS, you are then able to use it the following way:

apns_platform = Platform.objects.create(
    platform='APNS',
    application=app,
    arn=settings.ARN_TOKEN_APNS
)

Does that make sense to you?

marcosh72 commented 5 years ago

Ah, got it! Will try this new approach. Thanks a lot!