title: Django Push Notification for IOS safari
body: <p>I used <a href="https://github.com/jazzband/django-push-notifications" rel="nofollow noreferrer">django-push-notifications</a> for implementing push notifications in <code>Django</code> server.</p>
  
  <p>I have implemented <code>GCM</code> for my <code>AngularJS</code> webapp and its working great on chrome. For safari I'm following <a href="https://medium.com/anantha-krishnan-k-g/safari-push-notifications-ec171bdf6ead" rel="nofollow noreferrer">this post</a> for implementing <code>APNS</code> part but I get this error:</p>
  
  <pre><code>"POST /v1/pushPackages/web.com.example HTTP/1.1" 200 5722
  {u'logs': [u'downloading push notification package failed']}
  </code></pre>
  
  <p>This is my <strong>views.py</strong></p>
  
  <pre><code>@api_view(['POST','GET'])
  def getPushPackage(request):
      try:
          print "Here -- &gt; Hello"
          filename = '/pushNotifications/static/pushPackage.zip'
          zipfile = open(settings.BASE_DIR+filename, 'rb')
          response = HttpResponse(content=zipfile)
          response['Content-Type'] = 'application/zip'
          response['Content-Disposition'] = 'attachment; filename="%s"' %(settings.BASE_DIR+filename)
          print "Here -- &gt; Done"
          return response
          # return HttpResponse(content=zipfile, content_type='application/force-download')
      except Exception as e:
          print str(e)
          return Response(str(e))
  </code></pre>
  
  <p>This is my <strong>urls.py</strong></p>
  
  <pre><code>url(r'^v2/pushPackages/web.com.example', views.getPushPackage),
  url(r'^v1/log', views.printPushError),
  </code></pre>
  
  <p>This is my <strong>Controller</strong></p>
  
  <pre><code>var checkRemotePermission = function (permissionData) {
      console.log(permissionData.permission);
      if (permissionData.permission === 'default') {
          // This is a new web service URL and its validity is unknown.
          window.safari.pushNotification.requestPermission(
              'https://x.x.x.x:1234', // The web service URL.
              'web.com.example',
              {}, // Data that you choose to send to your server to help you identify the user.
              checkRemotePermission         // The callback function.
          );
      }
      else if (permissionData.permission === 'denied') {
          console.log("here user denial");
          // The user said no.
      }
      else if (permissionData.permission === 'granted') {
          // The web service URL is a valid push provider, and the user said yes.
          console.log("here");
          console.log(permissionData.deviceToken);
          // permissionData.deviceToken is now available to use.
      }
  };
  
  // functions end
  if(browser == "Safari")
  {
      console.log( "In safari" );
      if ('safari' in window &amp;&amp; 'pushNotification' in window.safari) {
          var permissionData = window.safari.pushNotification.permission('web.com.example');
          checkRemotePermission(permissionData);
      }
  }
  </code></pre>