How to control snooze button for Alarm Class in WP7 - windows-phone-7.1

I used the following code to `private static void CreateAlarm(double time)
{
var alarm = new Alarm("MyAlarm")
{
Content = "You have a meeting with your team now.",
Sound = new Uri("/Sounds/preview.mp3", UriKind.Relative),
BeginTime = DateTime.Now.AddSeconds(time)
};
ScheduledActionService.Add(alarm);
}`
to create an alarm clock for Windows Phone 7.As Alarm starts ,it gives "snooze" and "dismiss" option.When I click the snooze button,it takes me to my first page but I want to set snooze for 9min always.Someone told me that we cannot control snooze button but I think its very simple and there would be someway to do it.

You cant do this. However, in Mango (WP7.5) the snooze is already 9 minutes.

Related

Handler of addUIInterruptionMonitor is not called for Alert related to Photos

private func acceptPermissionAlert() {
_ = addUIInterruptionMonitor(withDescription: "") { alert -> Bool in
if alert.buttons["Don’t Allow"].exists { //doesnt get here second time
alert.buttons.element(boundBy: 1).tapWhenExists()
return true
}
return false
}
}
and this doesn't work for:
In the beginning of the app, it works perfect while accepting permission for notifications, but here, it doesn't work. Why is this?
I'vs found that addUIInterruptionMonitor sometimes doesn't handle an alert in time, or until tests have finished. If it isn't working, try using Springboard, which manages the iOS home screen. You can access alerts, buttons, and more from there, and this is particularly useful for tests where you know exactly when an alert will show.
So, something like this:
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let alertAllowButton = springboard.buttons.element(boundBy: 1)
if alertAllowButton.waitForExistence(timeout: 5) {
alertAllowButton.tap()
}
The buttons.element(boundBy:1) will ensure you tap the button on the right, change 1 to 0 to tap the left, (because sometimes the ' in "Don't Allow" causes a problem).
Add:
app.tap()
at the end of the method.
This is because you need to interact with the app for the handler to fire.
After adding the interruption monitor, you should continue to interact with the app as if it has not appeared.
Also note that you have a 'smart quote' in your button identifier, instead of a regular apostrophe.
let photosAlertHandler = addUIInterruptionMonitor(withDescription: "Photo Permissions") { alert -> Bool in
if alert.buttons["Don't Allow"].exists {
alert.buttons.element(boundBy: 1).tapWhenExists()
return true
}
return false
}
// Do whatever you want to do after dismissing the alert
let someButton = app.buttons["someButton"]
someButton.tap() // The interruption monitor's handler will be invoked if the alert is present
When the next interaction happens after the alert appears, the interruption monitor's handler will be invoked and the alert will be handled.
You should also remove the interruption monitor when you think you're done with it, otherwise it will be invoked for any other alerts that appear.
removeUIInterruptionMonitor(photosAlertHandler)

setting a reminder to a iphone calendar with xamarin

I am trying to add a reminder to an iphone with my app. I can add the reminder with an alarm that will ring at the specified time but it wont show up as a reminder in the phones pull down list like adding a reminder in siri does.
here is the code I have so far:
public void AddReminder()
{
EKReminder reminder = EKReminder.Create(eventStore);
reminder.Title = "Do something awesome!";
// an error for the reminders and calendars
NSError e = new NSError();
// an alarm time
EKAlarm timeToRing = new EKAlarm();
timeToRing.AbsoluteDate = NSDate.Now.AddSeconds(61);
reminder.AddAlarm(timeToRing);
reminder.Notes = "do something noteworthy";
//reminder.Calendar = calendar;
reminder.Calendar = eventStore.DefaultCalendarForNewReminders;
eventStore.SaveReminder(reminder, true, out e);
}
I have a button the the main page of the form that will call this function. And I have all of the setup for the event store to get the permission and so forth.

is there a way to let the user choose the sound for local notification?

I have an app that has 64 local notifications with repeat intervals. So I can't add more notifications, or otherwise, I'd need the user to open the app again for a reschedule.
I was wondering if I'm able to let the user choose the file with in this code:
notif.soundName = #"xxx.wav";
so they can choose xyz.wav instead?
Yes, you can let the user choose the sound between some that are already in your project or you could also let him take a song from the music library.
Update:
If the files are already in your Xcode project, you can create a NSString or a int value to store the user choose. You create a button that let the user choose a sound. You connect this button to change the string or int value. Then you create and if statement that check this string or int and change properly the UILocalnotification sound.
int soundNumber;
- (IBAction)chooseSoundName {
soundNumber = 1;
}
- (void)loadSoundName {
if(SoundNumber == 1) {
localNotification.soundName = #"first.wav";
}
}
Then you call the loadSoundName method (or you could integrate it into another method).
Hope it helps

APN custom notification sound issue

I have remote notifications setup and working fine. I however have to play a custom sound when a notification is received (when app is NOT in foreground). I have added a file called customSound.wav to my app bundle and made sure "add to targets" is selected when i drag and drop it into my project (is this the correct way?). Server-side: the same file name has been specified as "sound": "customSound.wav". In my didReceiveRemoteNotification i am printing the userInfo dictionary and it is coming up like this:
aps =
{
alert = "Good Evening Sir";
badge = 1;
"custom_filed1" = 1;
"custom_field2" = "AAA-BBB-CCC";
name = "Sir Hubert";
sound = default;
};
As you can see, sound is still "default". I am aware of the fact that if the sound specified can not be found, the default sound is played- will the sound value in the dictionary also be "default" or it should be the file name that was specified in payload json. Is the order in which these are specified in the payload important. I have tried suggestions from other threads but not working for me. I can not show the json as I do not have access to the system at the moment. Any suggestions as to what I may be doing wrong ?
No your sound key should have the sound file name you want to play.
{
aps =
{
alert = "message";
sound = "sound file name.extension";
badge = 1;
};
}
eg:
{
aps =
{
alert = "message";
sound = "tone.caf";
};
}
I am using this and getting successful custom alert on my notification;
keep sound duration as small as possible. I did with this file format: aiff, caf
if u want to test notification then u can try this app https://itunes.apple.com/us/app/easy-apns-provider-push-notification/id989622350?mt=12
I am not doing any marking of this app but it is good for testing push notification

Control sound to only play once in XNA

I use a sound each time a key is pressed to fire a missile. But it doesn't sound nice. I guess it's because the the sound is repeated so many times while the key is pressed down and that the code is within the Update method. I'm looking for a simple solution to just play the sound once when key is pressed? (I have tested to use a boolean variable to be true the first time and then false after det the sound has been played, but this didn't worked well because, when and where should I set it to true again) Help is preciated!
// Fire
if (keyboardState.IsKeyDown(Keys.Space))
{
missile.launchMissile(spaceship.spaceshipPosition, spaceship.spaceshipDirection);
soundExplosion.Play();
}
EDIT New code that isn't working!?
KeyboardState keyboardState = Keyboard.GetState();
KeyboardState prevKeyboardState;
prevKeyboardState = keyboardState;
keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Keys.Space) && prevKeyboardState.IsKeyUp(Keys.Space))
{
missile.launchMissile(spaceship.spaceshipPosition, spaceship.spaceshipDirection);
soundExplosion.Play();
}
Store your previous keyboard state as well
KeyBoardState prevKeyboardState;
then in your update
prevKeyboardState = keyboardState;
keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Keys.Space) && prevKeyboardState.IsKeyUp(Keys.Space))
{
//your code
}
You're basically just triggering the sound tons of times every second making it sound awful.

Resources