0

Step 01: I can run my app (APP NAME : TextDetectAPP)

Step 02: User press Home button

Step 03:User open the Skype or any third party app (APP NAME : TextDetectAPPMove to Background state )

Spep04: User copy text (I need to get copy text from Skype or or any third party app )

Note :

  • UIpasteboard is working fine only user developed apps in iOS swift

  • Shall we have access rights to read text messages from Skype , whats up or any thirds parts apps in iOS swift?

Thanks in Advance

suripappu Rengan
  • 61
  • 1
  • 1
  • 5
  • Did you try `UIPasteBoard.general()` ? And see if you can get strings from other apps? – badhanganesh Mar 14 '18 at 07:27
  • @BadhanGanesh:- yes . UIPasteBoard.general is used only for user developed apps. How about third party apps like skype,whatsup and so on . I want to access third party for copy messages using swift ios . after moves to back ground state , how our app came to know user current application in ios swift . Even i have tried current applcation, its works in osx only not an ios device . – suripappu Rengan Mar 14 '18 at 08:22

1 Answers1

0

If I understand your question right, you want to get texts that were copied in other apps (Skype, FB etc.). You can do this using the UIPasteboard class. Usually texts are copied to the general pasteboard and you can access it without any problems (I've tried with Skype and Message (iOS) applications, it is working). When you open your app back, you can get the copied text from third party apps like this in the applicationDidBecomeActive delegate method:

func applicationDidBecomeActive(_ application: UIApplication) {
    if let clipboardString = UIPasteboard.general.string {
        print(clipboardString)
    }
}

You can also use UIPasteboardChanged notification to listen to changes in pasteboard, however you cannot receive change notifications from other apps. Also your app may not be in background state all the time executing code (unless you enable some specific background modes like Audio, Airplay etc.). So there is no way for you to get the copied texts when you are in background. You either need to use the method above, (or) if your app supports background execution, you can have an NSTimer fire every n seconds that gets the pasteboard content.

badhanganesh
  • 3,427
  • 3
  • 18
  • 39
  • Badhan Ganesh:- Thanks .Doing great.Can I get text while user copy text in Skype , at the time ,shall we get text in Skype itself, not move to user app? Actually app is running in background state , at the how we can get text of Skype & so on third party apps ? – suripappu Rengan Mar 14 '18 at 09:38
  • @suripappuRengan No you cannot achieve that. See edited answer. – badhanganesh Mar 14 '18 at 10:41
  • @suripappu Rengan Did the answer work? If yes, mark the answer as accepted. Or if you have fixed with a different solution, pls post it as an answer here so that other people can benefit from it. – badhanganesh Mar 18 '18 at 13:13
  • No. It can't be fixed in iOS . – suripappu Rengan Mar 19 '18 at 05:58