在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:bobeast/PushPlugin-deprecated开源软件地址:https://github.com/bobeast/PushPlugin-deprecated开源编程语言:Java 71.0%开源软件介绍:Cordova Push Notifications Plugin for Android and iOSDESCRIPTIONThis plugin is for use with Cordova, and allows your application to receive push notifications on both Android and iOS devices. The Android implementation uses Google's GCM (Google Cloud Messaging) service, whereas the iOS version is based on Apple APNS Notifications Important - Push notifications are intended for real devices. The registration process will fail on the iOS simulator. Notifications can be made to work on the Android Emulator. However, doing so requires installation of some helper libraries, as outlined here, under the section titled "Installing helper libraries and setting up the Emulator". LICENSE
Manual Installation for AndroidAdd the com.google.android.gcm and com.plugin.GCM packages to your project's src directory. Modify your AndroidManifest.xml and add the following lines to your manifest tag, replacing your_app_package with your app's package path:
Modify your AndroidManifest.xml and add the following lines to your application tag, replacing your_app_package with your app's package path:
Modify your res/xml/plugins.xml to include the following line in order to tell Cordova to include this plugin and where it can be found:
Add the PushNotification.js script to your assets/www folder (or javascripts folder, wherever you want really) and reference it in your main index.html file.
Manual Installation for iOSCopy the following files to your project's Plugins folder:
Add a reference for this plugin to the plugins dictionary in Cordove.plist:
Add the PushNotification.js script to your assets/www folder (or javascripts folder, wherever you want really) and reference it in your main index.html file.
Automatic InstallationThis plugin is based on pluginstall. to install it to your app, simply execute pluginstall as follows;
For additional info, take a look at the Cordova Pluginstall Specification Plugin APIIn the Examples folder you will find a sample implementation showing how to interact with the PushPlugin. Modify it to suit your needs. First create the plugin instance variable.
When deviceReady fires, get the plugin reference
registerThis should be called as soon as the device becomes ready. On success, you will get a call to tokenHandler (iOS), or onNotificationGCM (Android), allowing you to obtain the device token or registration ID, respectively. Those values will typically get posted to your intermediary push server so it knows who it can send notifications to.
successHandler - called when a plugin method returns without error
errorHandler - called when the plugin returns an error
tokenHandler (iOS ony) - called when the device has registeredwith a unique device token.
senderID (Android only) - This is the Google project ID you need to obtain by registering your application for GCM ecb - event callback that gets called when your device receives a notification
unregisterCall this when your app is exiting to cleanup any used resources.
setApplicationIconBadgeNumber (iOS only)set the badge count visible when the app is not running
badgeCount - an integer indicating what number should show up in the badge. Passing 0 will clear the badge. Test EnvironmentThe notification system consists of several interdependent components.
This plugin and its target Cordova application comprise the client application.The APNS and GCM infrastructure are maintained by Apple and Google, respectively. In order to send push notifications to your users, you would typically run an intermediary server or employ a 3rd party push service. This is true for both GCM (Android) and APNS (iOS) notifications. However, when testing the notification client applications, it may be desirable to be able to push notifications directly from your desktop, without having to design and build those server's first. There are a number of solutions out there to allow you to push from a desktop machine, sans server. The easiest I've found to work with is a ruby gem called pushmeup. I've only tried this on Mac, but it probably works fine on Windows as well. Here's a rough outline; Prerequisites.
Get the gem, either by downloading the zip or cloning the repo.1)
Follow this tutorial to create a file called ck.pem.2) (iOS)Start at the section entitled "Generating the Certificate Signing Request (CSR)", and substitute your own Bundle Identifier, and Description.
Follow these steps to generate a project ID and a server based API key.3) (Android)
4) Push a notification
If all went well, you should see a notification show up on each device. If not, make sure you are not being blocked by a firewall, and that you have internet access. Check and recheck the token id, the registration ID and the certificate generating process. In a production environment, your app, upon registration, would send the device id (iOS) or the registration id (Android), to your intermediary push server. For iOS, the push certificate would also be stored there, and would be used to authenticate push requests to the APNS server. When a push request is processed, this information is then used to target specific apps running on individual devices. If you're not up to building and maintaining your own intermediary push server, there are a number of commercial push services out there which support both APNS and GCM. kony and many others. NotesIf you run this demo using the emulator you will not receive notifications from GCM. You need to run it on an actual device to receive messages or install the proper libraries on your emulator (You can follow this guide under the section titled "Installing helper libraries and setting up the Emulator") If everything seems right and you are not receiving a registration id response back from Google, try uninstalling and reinstalling your app. That has worked for some devs out there. While the data model for iOS is somewhat fixed, it should be noted that GCM is far more flexible. The Android implementation in this plugin, for example, assumes the incoming message will contain a 'message' and a 'msgcnt' node. This is reflected in both the plugin (see GCMIntentService.java) as well as in provided example ruby script (pushGCM.rb). Should you employ a commercial service, their data model may differ, in which case the plugin will need to me modified to accommodate those differences. Additional ResourcesLocal and Push Notification Programming Guide (Apple) Google Cloud Messaging for Android (Android) Apple Push Notification Services Tutorial: Part 1/2 Apple Push Notification Services Tutorial: Part 2/2 How to Implement Push Notifications for Android AcknowledgmentsHuge thanks to Mark Nutter whose GCM-Cordova plugin forms the basis for the Android side implimentation. Likewise, the iOS side was inspired by Olivier Louvignes' Cordova PushNotification Plugin (Copyright (c) 2012 Olivier Louvignes) for iOS. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论