global name 'APNApplication' is not defined Error
Closed this issue · 4 comments
I am using the Scarface Framework and getting this error: global name 'APNApplication' is not defined. The code is:
def register(self, request, pk=None):
"""
registers the device to sns
:param your_device_instance: the device
:param token: the push token or the registration id
"""
device = self.get_object()
token = device.token
# get the correct notification plattform
application_plattform = APNApplication()
# register the application
application_plattform.register()
# create the device resource with the token (may be the push token or the registration id)
sns_device = SNSDevice(application_plattform, token)
# register the device with sns or update the token/the attributes
sns_device.register_or_update(new_token=token, custom_user_data="customer_name={0}".format(Device.dealer.full_name))
# this is importat: after updating or registration, your sns resource should have a arn. save this to your database.
if sns_device.arn:
device.arn = sns_device.arn
device.save()
Can you help here? do you have any idea what could be the problem?
Thanks
Just to check. Did you import APNApplication?
from scarface.models import SNSDevice, APNApplication
No I didn't since it is not in the documentation... I will add it. It will be great if you can add it to the doc as part of the setting.
Thanks a lot!
Already added it. Thank you for your input.
Additional help is needed...
While this command is executed: application_plattform.register(),
I am getting this error:
Exception Type: BotoServerError
Exception Value:
BotoServerError: 400 Bad Request
{"Error":{"Code":"InvalidParameter","Message":"Invalid parameter: PlatformPrincipal not valid.","Type":"Sender"},"RequestId":"d027b359-0dd4-5296-9dd9-fe748596113c"}
Exception Location: C:\Python27\lib\site-packages\boto\sns\connection.py in _make_request, line 765
Any idea?
Thanks