How to create a global environment variable that can be accessed by SpringBoard or other applications in the jailbroken iPhone?

前端 未结 2 2000
醉话见心
醉话见心 2021-01-22 12:48

I found that a variable created in SpringBoard can not be accessed by other regular applications. But now I want to make a flag variable that can share status in the global env

相关标签:
2条回答
  • 2021-01-22 13:25

    You can store your var in the keyChain, and make all app which wanna share it in one access group. Hope it help.

    0 讨论(0)
  • 2021-01-22 13:44

    You can try combination of a file with notifications of changes in this file. Notifications between processes can be sent in two ways:

    1. Darwin notification center CFNotificationCenterGetDarwinNotifyCenter
    2. Distributed notification center CFNotificationCenterGetDistributedCenter - private API

    Distributed notification center is better because you can send notification with some data attached to it. Darwin notification center ignores all user info passed to it. So when you changed some flag and saved it in a file you can send notification with this flag's new value. You don't even need to open file and get flag's value yourself. All other apps just need to listen for this notification.

    Here is CFNotificationCenterGetDistributedCenter prototype

    CFNotificationCenterRef CFNotificationCenterGetDistributedCenter();
    

    Update:

    This function is available in iOS 5.0 and above. If you need to support older versions there are two solutions:

    1. Darwin notification center
    2. CFMessagePort - can transmit arbitary data.

    If you really need to support older versions I suggest you using CFMessagePort. It's simple and flexible solution, well documented. If you having troubles with it you can always find working examples.

    0 讨论(0)
提交回复
热议问题