How to test Push Notification is working in my application

前端 未结 10 2279
我在风中等你
我在风中等你 2020-12-23 11:42

In my application I am implementing the Push Notification Service.
I have a Content Provider server, which contains some products in it.
I have generated the SSL Cli

相关标签:
10条回答
  • 2020-12-23 12:00

    PushMeBaby is frozen when I test iOS10 in Xcode8. Try NWPusher, https://github.com/noodlewerk/NWPusher. A friendly and simple tool with GUI.

    0 讨论(0)
  • 2020-12-23 12:01

    Very cool guide is posted here: Programming Apple Push Notification Services

    And an application named PushMeBaby Mac Os App which you can download and use for sending push-notifications to your devices from a Mac.

    APNS will send the push notification to your device as soon as your device will become available. If I've not mistaken your device pings APNS every minute.

    0 讨论(0)
  • 2020-12-23 12:01

    You should try the the branch of PushMeBaby, it worked for me.

    0 讨论(0)
  • 2020-12-23 12:01

    I created a small script to do that

    import json
    import jwt
    import time
    
    from hyper import HTTPConnection
    
    ALGORITHM = 'ES256'
    
    # fill these items
    APNS_KEY_ID = ''
    TEAM_ID = ''
    BUNDLE_ID = ''
    
    # put path to p8 file
    APNS_AUTH_KEY = ''
    
    # put device token id (of the notification receiver)
    REGISTRATION_ID = ''
    
    # let's do the magic :)
    f = open(APNS_AUTH_KEY)
    secret = f.read()
    
    token = jwt.encode(
        {
            'iss': TEAM_ID,
            'iat': time.time()
        },
        secret,
        algorithm= ALGORITHM,
        headers={
           'alg': ALGORITHM,
            'kid': APNS_KEY_ID,
       }
    )
    
    path = '/3/device/{0}'.format(REGISTRATION_ID)
    
    equest_headers = {
    'apns-expiration': '0',
    'apns-priority': '10',
    'apns-topic': BUNDLE_ID,
    'authorization': 'bearer {0}'.format(token.decode('ascii'))
    }
    
    connection = HTTPConnection('api.development.push.apple.com:443')
    
    # put the payload you need
    payload_data = {
    'aps': {
     'content-available': '1',
     },
    }
    payload = json.dumps(payload_data).encode('utf-8')
    
    connection.request(
    'POST',
    path,
    payload,
    headers=request_headers
    )
    resp = connection.get_response()
    
    print(resp.status)
    print(resp.read())
    

    https://gist.github.com/IvanivOleg/7ba4072128b2c05a068a6826be68a3d3

    0 讨论(0)
  • 2020-12-23 12:04

    You can use APNS tester,its a very good tool for test APNS from Mac Machine link to download this software. 2 things you need to provide to test push notification

    1.APNS certificate (.cer file) 2.Device token of user's iOS device

    0 讨论(0)
  • 2020-12-23 12:06

    I tried all 3 of the above suggestions with no success. In case someone else is ends up here looking for a solution to this, I found this and it works great:

    Pusher https://github.com/noodlewerk/NWPusher

    0 讨论(0)
提交回复
热议问题