Sending notifications from Mac to iPhone/ iPad/ iPod touch

扶醉桌前 提交于 2019-12-19 04:12:55

问题


I currently sell a Mac-only productivity tool that uses visual and audio notifications to remind the user of certain events taking place.

I've started planning the iPhone and iPad versions of that Mac program and would like to be able to provide notification services from the Mac to the iPhone, e.g. instead of the Mac playing an audio cue, the iPhone could vibrate, etc.

I have so far done very little iPhone development and I'm not really sure how the various push notification services work. Is this easy enough to do? or is a "challenge".

A few more potentially relevant pieces of information:

  • there will be a Dropbox-based sync between the iPhone and the Mac versions, so there is also the possibility of "sharing" a file that would prompt some action

  • it might be acceptable as a first step to not have "background" notifications and require that the iPhone client is running

What authentication issues should I expect to deal with?


回答1:


You'll need to implement APNs (Apple Push Notification Service) in both your app and your server.

To clarify a few things:

  1. You'll need a server doing those transferring messages job between the user's Mac/PC and their iDevices.
  2. Your server will decide when to push what kind of notification to which user's device.
  3. After that, your server sends a message to Apple's APNs server, which will push that message on your behalf.
  4. It's absolutely OK that your app can be in the background or even closed when the APNs message arrives at the user's device. The user will be guided by the OS to open your app.
  5. If the user has explicitly disabled your app's APNs function in her/his device, or, if the user cancels the APNs alert when it arrives, your app won't be launched if it originally stays in the background or if it hasn't been open yet.
  6. The user will be asked to enable (as you put it, authenticate) your app's APNs function by the OS in her or his device when your app is launched for the first time.

It's not a challenging task for an experienced iOS developer or an experienced PHP developer, since Apple's documents and APIs are pretty straightforward. However, configuration on the server side can be a little tricky.

I believe Stack Overflow already has tons of information on how to enable APNs in iOS apps. All you need to do is be specific in your question and do the search work beforehand.

Hope that helps.



来源:https://stackoverflow.com/questions/4689847/sending-notifications-from-mac-to-iphone-ipad-ipod-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!