什么是与APNS服务器交互并向iOS设备发送推送通知的最简单方法?

3

我在我的Web服务器上运行一个PHP/MySQL应用程序,我需要向iOS设备发送推送通知。

实现这个的最简单方法是什么?有没有我可以使用的PHP库?还是甚至有任何服务提供商在其中与APNS服务器进行交互呢?

你有什么经验?使用PHP实现推送通知需要多少工作量?

2个回答

3
最好的方法是使用API,如以下服务所提供的:
  1. Choose a Saas API that you will connect to your PHP/MySQL Application

    • Urbanairship
    • Pushwoosh
    • WonderPush
    • Appoxee
    • Pubnub
    • Xtify
    • prowlapp.com
    • mobdb.net
    • push.io
    • appnotifications
    • pushwizard
  2. Upload users

    I really recommend to use the SDK proposed by those services because the job they make is significant. They import user devices ID, with other informations such as app opens, behavior events... all you can use for segmenting your user base. Moreover, SDKs are the only way to display rich and in-app messages, and to track conversion.

    But if you really want to do without SDK, you can.

    For example with WonderPush Notifications API, because I know this one, you have to make the two following calls. You need first to login (it takes one second, it doesnt required credit card !) create your app and grab your client id.

    Then for each device, you just need to make the two following requests:

    curl -XPOST https://api.wonderpush.com/v1/authentication/accessToken \
        -d clientId=YOUR_APP_CLIENT_ID \
        -d devicePlatform=iOS \
        -d deviceId=DEVICE_ID
    
    curl -XPATCH https://api.wonderpush.com/v1/installation \
        -d accessToken=TOKEN_FROM_PREVIOUS_CALL \
        -d body='{"pushToken":{"data":{"DEVICE_PUSH_TOKEN"}}}'
    
  3. Notify your users

    This example is just for simple notification. You can go further with many advanced features, like HTML in app messages, custom events...

    curl -XPOST https://api.wonderpush.com/v1/management/deliveries \
        -d accessToken=SERVER_PRIVATE_ACCESS_TOKEN \
        -d applicationId=YOUR_APP_ID \
        -d segmentIds=@ALL \
        -d notificationOverride='{"type":"simple","text":"Hello, that's my message!","data":{"type":"simple"}}'
    

1

关于托管APNS服务的问题之前已经有了一个问题;然而,其中一些服务现在似乎已经关闭。

目前有两个服务:Urban AirshipiLime。两者都提供免费服务,直到达到一定数量的消息为止。我还没有使用过任何一个,所以无法评论它们的工作效果,但我知道Urban Airship自APNS早期就存在,这让人感到有点安心。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接