Problem description
Error when opening an app from local notification using Ti.App.getArguments()
Sample code and steps to reproduce
Run the sample code.
Local notification is correctly received. When clicking on the notification, everything works fine if the app is backgrounded. If the app is closed, an error is thrown and the app is not opened (see attached error log)
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var textArea = Ti.UI.createLabel({
text:'Launch Arguments: '+ Ti.App.getArguments(),
top:200
});
win1.add(textArea);
var button = Ti.UI.createButton({
width:200,
height:150,
title:'Create Notification'
});
win1.add(button);
var context = this;
button.addEventListener('click', function(e){
var notificationDate = new Date(new Date().getTime() + (20*1000));
context.notification = Ti.App.iOS.scheduleLocalNotification({
alertBody:'This is a sample notification',
date:notificationDate,
sound:'/alert.caf',
userInfo : {"reportId":3,"savedId":5},
alertAction:'View Report'
});
alert('Leave and kill this app, you will receive a notification in 60 secs');
});
win1.open();
Test instructions (on device): 1. Launch app, press button, wait 20 secs to get text area updated with "Notification: This is a sample notification" 2. Close and kill the app. 3. Launch app again, press button, press Home, kill app. 4. Wait 20 secs to on-screen notification to appear. 5. Click on notification to open the app. 6. Text area should be updated with "Notification: This is a sample notification" on start. Updated test case:
Tested with 3.0.0.v20121130200208 on iPhone 4 5.1.1
Reopening to update labels
Tested with: SDK:3.1.2.v20130718094558 Appcelerator Studio: 3.1.2.201307121651 OS: OSX 10.7.5 Device:iPhone5(ios6) Xcode: 4.6