{ "id": "172673", "key": "AC-6036", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2018-11-28T18:35:40.000+0000", "created": "2018-11-27T14:32:56.000+0000", "labels": [ "ios", "localnotification", "notification", "notifications", "schedulelocalnotification" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2018-11-28T18:35:40.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "I'm trying to attach an image, placed in the _Ti.Filesystem.applicationDataDirectory_, to a local notification.\r\nBut as soon as I do the _Ti.App.iOS.scheduleLocalNotification()_, the image is removed from the _Ti.Filesystem.applicationDataDirectory_\r\n\r\nExample: first click on \"Capture screen\", and then on \"Shedule notification\"\r\n\r\n\r\n{code:java}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : \"yellow\",\r\n\tlayout : \"vertical\"\r\n});\r\n\r\nvar imageView = Ti.UI.createImageView({\r\n\ttop : 50,\r\n\twidth : 200,\r\n\theight : 200,\r\n\tbackgroundColor : \"white\",\r\n\tborderWidth : 5,\r\n\tborderColor : \"white\"\r\n});\r\n\r\nvar captureScreenBtn = Ti.UI.createButton({\r\n\ttop : 20,\r\n\ttitle : \"Capture screen\",\r\n\twidth : Ti.UI.SIZE,\r\n\theight : Ti.UI.SIZE\r\n});\r\n\r\nvar notificationBtn = Ti.UI.createButton({\r\n\ttop : 20,\r\n\ttitle : \"Schedule notification\",\r\n\twidth : Ti.UI.SIZE,\r\n\theight : Ti.UI.SIZE\r\n});\r\n\r\ncaptureScreenBtn.addEventListener(\"click\",function(){\r\n\tvar imageBlob = win.toImage(null,true);\r\n\tvar imageUrl = Ti.Filesystem.applicationDataDirectory + \"image.jpg\";\r\n\tvar f = Ti.Filesystem.getFile(imageUrl);\r\n\tf.write(imageBlob);\r\n\timageView.image = imageUrl;\r\n\timageExists();\r\n});\r\n\r\nnotificationBtn.addEventListener(\"click\",function(){\r\n\tTi.App.iOS.scheduleLocalNotification({\r\n\t\tdate: new Date(new Date().getTime() + 5000),\r\n\t\talertBody: \"Test notification\",\r\n\t\tbadge: 1,\r\n\t\tuserInfo: {id:1},\r\n\t\talertLaunchImage : \"appicon.png\",\r\n\t\tsound : \"default\",\r\n\t\tattachments: [{\r\n\t\t\tidentifier: \"1\",\r\n\t\t\turl: Ti.Filesystem.applicationDataDirectory + \"image.jpg\"\r\n\t\t}],\r\n\t\tidentifier: \"1\"\r\n\t});\r\n\tsetTimeout(function(){\r\n\t imageView.image = Ti.Filesystem.applicationDataDirectory + \"image.jpg\"\r\n\t imageExists();\r\n\t},100)\r\n\t\r\n});\r\n\r\nfunction imageExists(){\r\n\tvar f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + \"image.jpg\");\r\n\talert('\"image.jpg\" exists? ' + f.exists());\r\n}\r\n\r\nwin.addEventListener('open', function() {\r\n Ti.App.iOS.registerUserNotificationSettings({\r\n types: [\r\n Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,\r\n Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,\r\n Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE\r\n ]\r\n });\r\n});\r\n\r\nwin.add(imageView);\r\nwin.add(captureScreenBtn);\r\nwin.add(notificationBtn);\r\nwin.open();\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "iOS: image placed in the applicationDataDirectory is removed if used as an attachment in a scheduleLocalNotification", "creator": { "name": "astrovicapps", "key": "astrovicapps", "displayName": "Vittorio Sorbera", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "astrovicapps", "key": "astrovicapps", "displayName": "Vittorio Sorbera", "active": true, "timeZone": "Europe/Berlin" }, "environment": "macOS 10.13.6; iOS 12.1; SDK 7.5.0.GA", "comment": { "comments": [ { "id": "443927", "author": { "name": "astrovicapps", "key": "astrovicapps", "displayName": "Vittorio Sorbera", "active": true, "timeZone": "Europe/Berlin" }, "body": "I've also tried with files placed in applicationCacheDirectory and tempDirectory. Also in this case the image is removed.\r\nI have also tried with PNG files, but the problem persists.\r\nThe issue does not occur if the image is placed in assets folder instead", "updateAuthor": { "name": "astrovicapps", "key": "astrovicapps", "displayName": "Vittorio Sorbera", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-27T15:17:26.000+0000", "updated": "2018-11-27T15:17:26.000+0000" }, { "id": "443988", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "That's native behavior if you try to attach files. iOS will validate the files you try to attach and move them afterwards. Please see the following note for [UNNotificationAttachment|https://developer.apple.com/documentation/usernotifications/unnotificationattachment?language=objc#overview]\r\n\r\n{quote}The system validates attachments before displaying the associated notification. If you attach a file to a local notification request that is corrupted, invalid, or of an unsupported file type, the system doesn't schedule your request. For remote notifications, the system validates attachments after your notification service app extension finishes. Once validated, attached files are moved into the attachment data store so that they can be accessed by all of the appropriate processes. Attachments located inside an app’s bundle are copied instead of moved.{quote}\r\n\r\nThis explains why the files in the asset folder are still there, but getting moved from all other directories. Create a copy of the file if you wan't to attach to avoid that your original file gets moved.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-28T10:45:16.000+0000", "updated": "2018-11-28T10:48:07.000+0000" }, { "id": "443991", "author": { "name": "astrovicapps", "key": "astrovicapps", "displayName": "Vittorio Sorbera", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks, now it's clear. At this point it is convenient save the image in the applicationDataDirectory and, just before the scheduleLocalNotification(), copy it in the tempDirectory and use this copy as image to attach. Thus the image should be first correctly scheduled and then removed", "updateAuthor": { "name": "astrovicapps", "key": "astrovicapps", "displayName": "Vittorio Sorbera", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-28T15:02:16.000+0000", "updated": "2018-11-28T15:02:16.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }