Advice on external please

Are you developing an External using the LiveCode Externals SDK?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Advice on external please

Post by doobox » Fri Jul 05, 2013 10:42 pm

hi there,

I am close to finishing my first external, to schedule a local notification with a specified sound file.
I am just getting into obj-c so am really struggling here, and would be most grateful if some one with experience could pass an eye over this
to make sure i am not doing anything badly wrong.
It currently works but as you can see the parameters are currently static.

I will update the code below if and when i manage to learn how i pass in the parameter i need to pass from the function call in LC



//
// dooboxNotify.mm
// dooboxNotify
//
// Created by Joseph Gary Simpson on 05/07/2013.
// Copyright 2013 __Doobox__. All rights reserved.
//


#import "UIKit/UIDevice.h"
#import "UIKit/UILocalNotification.h"
#import "Foundation/Foundation.h"
#import "UIKit/UIApplication.h"



bool dooboxNotifyStartup (void)
{

}


void dooboxNotifyShutdown (void)
{

}



// Not sure how to pass in the parramaters for my
// soundfile name, alert body, time, and alert action yet.
// As you see the vars are currently static for testing.
bool dooboxNotifySetNotification (void)
{
// create an instance of UILocalNotification
UILocalNotification * myNotificationObj = [[UILocalNotification alloc]init];

// set the vars
NSDate *currentDate = [NSDate date];
NSDate *dateToFireNotification = [currentDate dateByAddingTimeInterval:60];
NSString *alertBody = [[NSMutableString alloc] initWithString:@"Merry Christmas"];
NSString *alertAction = [[NSMutableString alloc] initWithString:@"HO HO HO"];
NSString *soundfileName = [[NSMutableString alloc] initWithString:@""];

// add the parramaters
myNotificationObj.fireDate = dateToFireNotification;
myNotificationObj.timeZone = [NSTimeZone defaultTimeZone];
myNotificationObj.alertBody = alertBody;
myNotificationObj.alertAction = alertAction;
myNotificationObj.alertLaunchImage = nil;

// sound file
if(soundfileName == nil)
{
myNotificationObj.soundName = UILocalNotificationDefaultSoundName;
}
else
{
myNotificationObj.soundName = soundfileName;
}

// fire it of
[[UIApplication sharedApplication] scheduleLocalNotification:myNotificationObj];
[myNotificationObj release];
// not sure if a really need to release the following
[currentDate release];
[alertBody release];
[alertAction release];
[soundfileName release];


return true; // for testing in LC
}
Kind Regards
Gary

https://www.doobox.co.uk

Post Reply

Return to “Building Externals/Plugins”