Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10684] iOS: Ti.App.getArguments() fails when opening the app from a local notification

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-07-19T11:52:58.000+0000
Affected Version/sRelease 2.1.2
Fix Version/sRelease 3.0.0, Sprint 2012-19 Core, 2012 Sprint 19
ComponentsiOS
LabelsSupportTeam, core, module_notification_manager, qe-testadded
ReporterFederico Casali
AssigneeMax Stepanov
Created2012-08-28T02:50:19.000+0000
Updated2013-07-19T11:52:58.000+0000

Description

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();

Attachments

FileDateSize
timob10681.log2012-08-28T02:50:19.000+00004656

Comments

  1. Max Stepanov 2012-09-14

    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:
       // 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:100
       });
       
       Ti.App.iOS.addEventListener('notification', function(e) {
       	textArea.text = textArea.text + " Notification: "+e.alertBody;
       }); 
       
       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 20 secs');
       					
       });
       
       
       win1.open();
       
  2. Natalie Huynh 2012-12-04

    Tested with 3.0.0.v20121130200208 on iPhone 4 5.1.1
  3. Anshu Mittal 2013-07-19

    Reopening to update labels
  4. Anshu Mittal 2013-07-19

    Tested with: SDK:3.1.2.v20130718094558 Appcelerator Studio: 3.1.2.201307121651 OS: OSX 10.7.5 Device:iPhone5(ios6) Xcode: 4.6

JSON Source