{ "id": "174345", "key": "AC-6428", "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": null, "resolutiondate": null, "created": "2019-11-09T22:32:21.000+0000", "labels": [ "iOS13" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2019-11-12T10:32:02.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [], "description": "Using Ti SDK 8.2.0GA and iOS13.2 Simulator Titanium.UI.iOS.DocumentViewer is not showing any document, but only displays filename and filetype. Running on iOS11.0.1 Simulator it works as expected.\r\n\r\n\r\n{code}\r\n\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\n \r\nvar btn = Ti.UI.createButton({\r\n title: 'Open PDF'\r\n});\r\n \r\nbtn.addEventListener('click', openPDF);\r\n \r\nwin.add(btn);\r\nwin.open();\r\n \r\n// Open the PDF file\r\nfunction openPDF() {\r\n var fileName = 'example.pdf';\r\n \r\n // For iOS 11.2, workaround the Apple issue by creating a temporary file and\r\n // reference it. It will be removed from filesystem once the app closes.\r\n // Read more here: http://nshipster.com/nstemporarydirectory/\r\n if (isiOS11_2()) {\r\n fileName = fileInTemporaryDirectory(fileName);\r\n }\r\n \r\n var docViewer = Ti.UI.iOS.createDocumentViewer({\r\n url: fileName\r\n });\r\n \r\n docViewer.show();\r\n}\r\n \r\n// Check if the current device runs iOS 11.2+\r\nfunction isiOS11_2() {\r\n\tvar version = Ti.Platform.version.split(\".\");\t\r\n\treturn (parseInt(version[0]) >= 11 && parseInt(version[1]) >= 2);\r\n}\r\n \r\n// Create a temporary file with the contents of the old file\r\n// Expects the file to be in the resources directory. If you receive the file \r\n// from an API-call, receive pass the Ti.Blob/Ti.File/text to \"write\" directly.\r\nfunction fileInTemporaryDirectory(fileName) {\r\n var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, fileName);\r\n \r\n if (!file.exists()) {\r\n alert('File does not exist in resources!');\r\n return;\r\n }\r\n \r\n var newFile = Titanium.Filesystem.getFile(Ti.Filesystem.tempDirectory, fileName);\r\n newFile.createFile();\r\n \r\n if (!newFile.exists()) {\r\n alert('New file could not be created in temporary directory!');\r\n return;\r\n }\r\n \r\n newFile.write(file);\r\n \r\n return newFile.nativePath;\r\n}\r\n{code}\r\n\r\n\r\n\r\n", "attachment": [ { "id": "67114", "filename": "screenshot.jpg", "author": { "name": "tw", "key": "tw", "displayName": "Thomas Weber", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-11-09T22:30:54.000+0000", "size": 199693, "mimeType": "image/jpeg" } ], "flagged": false, "summary": "iOS13: DocumentViewer not working", "creator": { "name": "tw", "key": "tw", "displayName": "Thomas Weber", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "tw", "key": "tw", "displayName": "Thomas Weber", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Ti SDK 8.2.0.GA\r\nSimulator iOS13.2\r\n(works on iOS11.0.1 simulator)", "comment": { "comments": [ { "id": "452591", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "The issue is the hard coded workaround:\r\n{code}\r\nreturn (parseInt(version[0]) >= 11 && parseInt(version[1]) >= 2);\r\n{code}\r\nThis would return {{false}} for iOS 12.1 and iOS 13.1. Instead, just check for iOS >= 11 or don't check at all, since caching the PDF for later file access is always a good idea.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-11-11T21:10:46.000+0000", "updated": "2019-11-11T21:10:46.000+0000" }, { "id": "452601", "author": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~tw] can you confirm it works if you follow [~hknoechel]'s instruction?", "updateAuthor": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-11-12T10:06:58.000+0000", "updated": "2019-11-12T10:06:58.000+0000" }, { "id": "452604", "author": { "name": "tw", "key": "tw", "displayName": "Thomas Weber", "active": true, "timeZone": "Europe/Berlin" }, "body": "Ok, it probably was not the best idea to simply copy the example code, but the simulator problem can also be reproduced with this example:\r\n\r\n{{var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, \"test.pdf\");\r\nvar docViewer = Ti.UI.iOS.createDocumentViewer({\r\n url: file.resolve()\r\n});\r\ndocViewer.show();}}\r\n\r\n\r\nSimulator\r\niOS 13.2 / Only shows filename and filetype (as on the screenshot)\r\nMacOS 10.14.6 / Xcode 11.2\r\n\r\nSimulator\r\niOS 11.0.1 / works\r\nMacOS 10.14.6 / Xcode 11.2\r\n\r\nDevice\r\niOS 13.2 / works\r\n", "updateAuthor": { "name": "tw", "key": "tw", "displayName": "Thomas Weber", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-11-12T10:32:02.000+0000", "updated": "2019-11-12T10:32:02.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }