5

It seems that in iOS 9/Xcode 7 beta 5, I am unable to access

[[UIPasteboard generalPasteboard] string];  

from my Today widget extension as every time no matter the contents, it returns (NULL). I looked through the release notes and I did not see anything regarding this.

Any ideas?

  • Just tried, and Xcode 7 GM fixes this issue in extensions =^) – Emmanuel G. Sep 09 '15 at 21:05
  • @EmmanuelG. , i'm using Xcode 7.0.1 (7A1001) and having same issue as "Isa Ranjha" please look on My Question http://stackoverflow.com/questions/33075125/uipasteboard-doesnt-work-in-ios9-xcode7-0 – Vatsal Shukla Oct 12 '15 at 07:14

2 Answers2

3

It seems to be an undocumented bug with iOS 9 beta 5, in particular, the iOS runtime. Same code works with normal app on iOS 9 beta 5, and today widget in iOS 8.x devices.

utogaria
  • 3,662
  • 2
  • 14
  • 12
  • Updates: According to new tests in Xcode 7 GM, the bug has been fixed by Apple. So, reading from pasteboard works as before. – utogaria Sep 14 '15 at 07:52
  • @utogaria nope this is not fix we are testing in xcode7.0.1 still same issue – Nitin Gohel Oct 12 '15 at 07:49
  • @NitinGohel I have just tried on iOS 9.0.2 (Xcode 7.0.1), everything works as expected. Additionally, I also tried on iOS 9.1 beta 4 (Xcode 7.1 beta 3), it also works. I suppose the problem you have might not be caused by the bug mentioned in this post. – utogaria Oct 12 '15 at 07:58
  • i told you about when app in background and you are copy text from safari and then open you app that you got nil instead of text. thats the main issue. – Nitin Gohel Oct 12 '15 at 09:09
2

My app, which is a password manager, needs to check the pasteboard's contents while in background to clear it after a while, so as to limit the users's password exposure.

The main app, while on background, is also getting nil from the [[UIPasteboard generalPasteboard] string] call. When it comes back to the foreground, it gets the correct data.

Because of that, I suspect this is a new and undocumented security/privacy feature and that there will be no "fixing".

Jorge Vasquez
  • 563
  • 1
  • 6
  • 13
  • 1
    That would be unfortunate although no release notes mentioned this change. From what I have heard, this is a bug. But we will see. –  Aug 11 '15 at 00:31
  • I hope my suspicions are wrong and your sources are right. :-) – Jorge Vasquez Aug 13 '15 at 19:21
  • 1
    I am getting ": Not allowing bundle ID (myapp.bundleid) access to the pasteboard while it's not foreground" in device console. I think in iOS 9 it will not be possible to get pasteboard data in background. – Ankur Gupta Sep 08 '15 at 12:44
  • 1
    Same type of app and rationale here. I'm finding I can *set* the pasteboard from the background, but not read it - the `string` on the pasteboard is always reported as (null) when backgrounded (even if the previous line set its contents). – davidjb Dec 19 '15 at 15:43