phonegap/cordova local notification plugin how i display notification in a specific date and time? - sencha-touch-2

I am working in sencha touch and now I want to use the local notification in my project so I used this plugin for the local notification.
https://github.com/katzer/cordova-plugin-local-notifications
the problem that I face is just that I can't display my notification on a specific time and date. It shows immediately the notification as i clicked on the action button so please help me out from this problem.

The example below should work. I tested it myself. Be aware that if the date is in the past according to your phone the notification will pop up directly after you have set the notification.
var beginTime = new Date('2016', '0', '12', '12', '45');
//year
//month - 1 (month starts at 0 so you have 0-11)
//day
//hour
//minutes
cordova.plugins.notification.local.schedule({
id: 1,
title: 'Hello World',
text: 'My first notification',
at: beginTime
})

Related

React native in app purchase not giving latest receipt

I am using react-native-iap package. I am trying to get latest subscription and check its validity
await RNIap.validateReceiptIos(receiptBody, true).then((receipt) => {
try {
const renewalHistory = receipt.latest_receipt_info
const expiration = renewalHistory[0].expires_date_ms
expired = Date.now() > expiration
productId = renewalHistory[0].product_id
} catch (error) {}
})
I am multiple auto renewal subscription in a single group. I subscribe to one and I execute code above give me the subscribed product and i tag it as subscribed. First try works fine. Now after that I subscribe again another package and run code above gives me the previous subscription not the current that i subscribed. Sometime second steps also works fine but issue came in third step. Reason I found is I am not getting latest subscribed receipt info in latest_receipt_info above.
Have a look to this tutoriel on YouTube it may help you : https://youtu.be/4JLHRV2kiCU
Also, here is what he said in the comment section :
where I write renewalHistory[renewalHistory.length - 1], this works fine in the test environment. HOWEVER, it seems that when the app is published, this doesn't work and you should instead do renewalHistory[0].
I fixed this in my app by first trying to validate using the production URL, using renewalHistory[0].
If you receive a 21007 status code after trying to validate with the production URL, you validate using the test URL using renewalHistory[renewalHistory.length - 1]

How to create local notification with an end date

I need to do local notification with an end date. I have taken look at https://wix.github.io/react-native-notifications/docs/localNotifications/ and https://github.com/zo0r/react-native-push-notification but cannot find an example of how it would work. I want a notification to have start and end date with an interval
This is answer is geared towards the second library you mentioned: https://github.com/zo0r/react-native-push-notification.
For setting the start date for when a notification should occur we have
the localNotificationSchedule method described in the documentation here: https://github.com/zo0r/react-native-push-notification#scheduled-notifications.
For example:
import PushNotification from 'react-native-push-notification';
PushNotification.localNotificationSchedule({
id: "1",
message: "My Notification Message", // (required)
date: new Date(Date.now() + 60 * 1000), // in 60 secs
// other props...
});
So whatever date object you pass to the date property will be the moment the notification is triggered.
Note that autoCancel by default has the value of true so after the notification is delivered the notification will be canceled anyway. So it's better not to handle the end date as it's already handled for you.
If you still want to cancel it anyway you can add autoCancel: true to the example above and cancel the notification like this:
PushNotification.cancelLocalNotifications({id: '1'});
So if you want to control the end date, an idea could be to first trigger your push notification and directly after call cancelLocalNotifications inside setTimeout. Then you could control when the notifications starts and when it is canceled.
If you want to have a way to do this in the background you can look into a background task library like https://github.com/transistorsoft/react-native-background-fetch.

How to schedule a notification with changing data expo

I am trying to make an app that utilizes expo's local notification feature and have run into an issue. I would like to make a notification that repeats every day at a certain interval with its data changing each day. I tried to use this syntax below, but it did not work as it only ran the function once, setting that value in stone for the rest of the notifications to come.
Expected (10 mins: "1", 20 mins: "2", 30 mins: "3" etc.)
Actual (10 mins: "1", 20 mins: "1", 30 mins: "1" etc.)
Notifications.scheduleNotificationAsync({
content: {
title: 'My Notification',
body: this.someFunctionThatReturnsANewValue()
},
trigger: {
minutes: 10,
repeats: true
}
});
In that case, I wanted to know if anyone had any idea on how to make a notification that uses the repeat property and has a body component that changes values each time it is triggered. The only other way I can think of giving a notification a different value as the last is scheduling 100+ notifications in advance, but that is not pretty nor practical. Any help or suggestions towards how I can accomplish this would be greatly appreciated, thanks!
In your component's useEffect or your application's App.js declare the Notifications.addNotificationReceivedListener event. It will be executed every time the application receives a new notification. Within the asynchronous function execute "await Notifications.cancelAllScheduledNotificationsAsync ();" to clear the scheduled notification and call Notifications.scheduleNotificationAsync again with the new message. The use of
repeats: true in this case is not necessary. Doing this, every time the application receives a notification it clears the one that existed before and programs a new one with a different message

Mandrill send API will queue email occasionally

My email will occasionally get queued instead of sending download link immediately using a paid Mandrill account- other times it will send quickly. I would like it to be send at time of calling the API. The are no errors in the Mandrill API control panel.
This code works great most of the time via a node server on Heroku...I am using 'send_at' parameter w current Date using the javascript Date() method. How can I send an email consistently - sometimes queues can be 1 hour 30 min long.
// Text version of message
me_data.text += message;
// Html for message
me_data.html = results['html'];
// current Date for sending
var sendDate = new Date();
mandrill_client.messages.send(
{"message": me_data, "async": async, "ip_pool": ip_pool, "send_at": sendDate},
function (result) {
console.log(result);
//success
},
function (e) {
//_____________________________Error
console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
}
);
This issue is no longer a problem. Please ignore the above posts about the time parameter as I am using this variable (clearly "send_at" from API doc) and Mandrill is sending.
This must have been a fluke of timing as I had paid a short time before launching production app. You have to pay (set credits) in Mandrill to use the send_at parameter - in other words upgrade from the free version. It may take some time to come into effect.
Mandrill has been working flawlessly since this issue like quick as lighting. So this is not an issue any longer for my stuff.

The Badge number is constantly increasing, even after I use the setBadgeNumber(0) method

I'm using the Distriqt PushNotifications ANE and PARSE to send PushNotifications, and so far everything is working PERFECTLY.
This means, I register my iOS devices and receive PushNotifications as it should be....
When I send PushNotifications with PARSE I use the badge:"Increment" value, which understandably increments the Value By +1.
After I open the App, I want to reset the BADGE to be at 0 and I use the setBadgeNumber(0) method... This also works, I tried with other values like 11, or 1 and it displays it correctly.
The Problem is that when I send another PARSE notification it displays now the old value + 1 !!!
Like so:
I use PARSE to send 3 PushNotifications
The badge displays (3)
I use the setBadgeNumber(0)
The badge displays (0)
I use PARSE to send 2 additional PushNotifications
The badge displays (5)!!!!
How can I really reset the badge?
The value of the badge is actually sent as part of the push notification payload, eg:
{
"aps" : {
"alert" : "Notification content",
"badge" : 5
}
}
You should double check what Parse is actually sending as it will be keeping a count of the notifications and sending that as part of the payload, so you will either need to disable this in Parse or notify Parse of your user resetting / changing the count.
Calling setBadgeNumber just changes the icon on the application and doesn't update Parse of this change.
You could look into the Parse ANE which helps out with this process:
http://airnativeextensions.com/extension/com.distriqt.Parse