Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Phonegap Plugin Push | 1,989 | 228 | 16 | 3 years ago | 62 | September 19, 2019 | 440 | mit | Java | |
Register and receive push notifications | ||||||||||
Nativescript Plugin Firebase | 1,000 | 125 | 10 | 2 years ago | 159 | November 05, 2020 | 537 | mit | TypeScript | |
:fire: NativeScript plugin for Firebase | ||||||||||
Firebasepushnotificationplugin | 377 | 16 | 12 | 4 months ago | 61 | October 11, 2022 | 124 | mit | C# | |
Firebase Push Notification Plugin for Xamarin iOS and Android | ||||||||||
Pushnotificationplugin | 202 | 5 | 6 | 5 months ago | 55 | November 10, 2022 | 29 | mit | C# | |
Push Notification Plugin for Xamarin iOS and Android | ||||||||||
Hms React Native Plugin | 193 | 2 | a month ago | 23 | July 18, 2022 | 11 | apache-2.0 | Java | ||
This repo contains all of React-Native HMS plugins. | ||||||||||
Fcm Push Plugin | 170 | 3 years ago | apache-2.0 | Kotlin | ||||||
IntelliJ IDEA plugin to send pushes using Firebase Cloud Messaging (FCM) | ||||||||||
Flutter Apns | 128 | 1 | 2 | 2 months ago | 18 | August 08, 2022 | 6 | bsd-3-clause | Dart | |
Flutter Plugin for Push notification servers | ||||||||||
Push Plugin | 123 | 18 | 10 | 4 years ago | 33 | September 13, 2018 | 36 | apache-2.0 | Objective-C | |
Contains the source code for the Push Plugin. | ||||||||||
Cordova Push Notification | 105 | 10 years ago | 5 | Objective-C | ||||||
Cordova ARC plugin for Push Notifications | ||||||||||
Hms Cordova Plugin | 80 | a month ago | 10 | April 29, 2022 | 6 | apache-2.0 | Java | |||
This repo contains all of Cordova HMS plugins. |
This plugin provides a simple way to use Apple Push Notifications (or Remote Notifications) from IOS.
This was inspired by the now orphaned ios-phonegap-plugin build by Urban Airship.
Using this plugin requires Cordova iOS.
Make sure your Xcode project has been updated for Cordova
Rename the src/ios
folder to PushNotification
, drag and drop it from Finder to your Plugins folder in XCode, using "Create groups for any added folders"
Add the .js files to your www
folder on disk, and add reference(s) to the .js files using <script>
tags in your html file(s)
<script type="text/javascript" src="/js/plugins/PushNotification.js"></script>
Add new entry with key PushNotification
and value PushNotification
to Plugins
in Cordova.plist/Cordova.plist
Make sure your provisioning profiles are set up to support push notifications. Here's a great tutorial.
This plugin requires modifications to your AppDelegate.h
. Append the following line just below other imports.
#import "PushNotification.h"
It also requires modifications to your AppDelegate.m
. Append the block below at the end of your file, just before the implementation @end
.
/* ... */
/* START BLOCK */
#pragma - PushNotification delegation
- (void)application:(UIApplication*)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
[pushHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication*)app didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
[pushHandler didFailToRegisterForRemoteNotificationsWithError:error];
}
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
NSMutableDictionary* mutableUserInfo = [userInfo mutableCopy];
// Get application state for iOS4.x+ devices, otherwise assume active
UIApplicationState appState = UIApplicationStateActive;
if ([application respondsToSelector:@selector(applicationState)]) {
appState = application.applicationState;
}
[mutableUserInfo setValue:@"0" forKey:@"applicationLaunchNotification"];
if (appState == UIApplicationStateActive) {
[mutableUserInfo setValue:@"1" forKey:@"applicationStateActive"];
[pushHandler didReceiveRemoteNotification:mutableUserInfo];
} else {
[mutableUserInfo setValue:@"0" forKey:@"applicationStateActive"];
[mutableUserInfo setValue:[NSNumber numberWithDouble: [[NSDate date] timeIntervalSince1970]] forKey:@"timestamp"];
[pushHandler.pendingNotifications addObject:mutableUserInfo];
}
}
/* STOP BLOCK */
@end
In order to support launch notifications (app starting from a remote notification), you have to add the following block inside - (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
, just before the return YES;
[self.window addSubview:self.viewController.view];
[self.window makeKeyAndVisible];
/* START BLOCK */
// PushNotification - Handle launch from a push notification
NSDictionary* userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if(userInfo) {
PushNotification *pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
NSMutableDictionary* mutableUserInfo = [userInfo mutableCopy];
[mutableUserInfo setValue:@"1" forKey:@"applicationLaunchNotification"];
[mutableUserInfo setValue:@"0" forKey:@"applicationStateActive"];
[pushHandler.pendingNotifications addObject:mutableUserInfo];
}
/* STOP BLOCK */
return YES;
Using this plugin requires Cordova Android.
Make sure your Android project has been updated for Cordova
Merge both the libs
and src
folder from this plugin to your projet.
Add the .js files to your assets/www
folder on disk, and add reference(s) to the .js files using <script>
tags in your html file(s)
<script type="text/javascript" src="/js/plugins/FacebookConnect.js"></script>
Add new entry with key PushNotification
and value org.apache.cordova.plugins.PushNotification
to Plugins
in res/xml/config.xml
// After device ready, create a local alias
var pushNotification = window.plugins.pushNotification;
registerDevice()
does perform registration on Apple Push Notification servers (via user interaction) & retrieve the token that will be used to push remote notifications to this device.
pushNotification.registerDevice({alert:true, badge:true, sound:true}, function(status) {
// if successful status is an object that looks like this:
// {"type":"7","pushBadge":"1","pushSound":"1","enabled":"1","deviceToken":"blablahblah","pushAlert":"1"}
console.warn('registerDevice:%o', status);
navigator.notification.alert(JSON.stringify(['registerDevice', status]));
});
getPendingNotifications()
should be used when your application starts or become active (from the background) to retrieve notifications that have been pushed while the application was inactive or offline. For now, it can only retrieve the notification that the user has interacted with while entering the app. Returned params applicationStateActive
& applicationLaunchNotification
enables you to filter notifications by type.
pushNotification.getPendingNotifications(function(notifications) {
console.warn('getPendingNotifications:%o', notifications);
navigator.notification.alert(JSON.stringify(['getPendingNotifications', notifications]));
});
getRemoteNotificationStatus()
does perform registration check for this device.
pushNotification.getRemoteNotificationStatus(function(status) {
console.warn('getRemoteNotificationStatus:%o', status);
navigator.notification.alert(JSON.stringify(['getRemoteNotificationStatus', status]));
});
setApplicationIconBadgeNumber()
can be used to set the application badge number (that can be updated by a remote push, for instance, resetting it to 0 after notifications have been processed).
pushNotification.setApplicationIconBadgeNumber(12, function(status) {
console.warn('setApplicationIconBadgeNumber:%o', status);
navigator.notification.alert(JSON.stringify(['setBadge', status]));
});
getApplicationIconBadgeNumber()
get the current value of the application badge number.
pushNotification.getApplicationIconBadgeNumber( function(badgeNumber) {
console.log('badgeNumber: ' + badgeNumber);
});
cancelAllLocalNotifications()
can be used to clear all notifications from the notification center.
pushNotification.cancelAllLocalNotifications(function() {
console.warn('cancelAllLocalNotifications');
navigator.notification.alert(JSON.stringify(['cancelAllLocalNotifications']));
});
getDeviceUniqueIdentifier()
can be used to retrieve the original device unique id. (@warning As of today, usage is deprecated and requires explicit consent from the user)
pushNotification.getDeviceUniqueIdentifier(function(uuid) {
console.warn('getDeviceUniqueIdentifier:%s', uuid);
navigator.notification.alert(JSON.stringify(['getDeviceUniqueIdentifier', uuid]));
});
Finally, when a remote push notification is received while the application is active, an event will be triggered on the DOM document
.
document.addEventListener('push-notification', function(event) {
console.warn('push-notification!:%o', event);
navigator.notification.alert(JSON.stringify(['push-notification!', event]));
});
Patches welcome! Send a pull request. Since this is not a part of Cordova Core (which requires a CLA), this should be easier.
Post issues on Github
The latest code (my fork) will always be here
The MIT License
Copyright (c) 2012 Olivier Louvignes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Inspired by :
Contributors :