pull notification locally on jailbroken device

前端 未结 3 1307
-上瘾入骨i
-上瘾入骨i 2020-12-05 20:29

Since the iOS framework doesn\'t allow local notifications to execute code before they are posted, I\'m looking for a way to achieve it on a jailbroken device.

3条回答
  •  再見小時候
    2020-12-05 21:12

    First of all, let me say that BigLex is giving quite interesting information. However, I never tried to write a deamon for jailbroken iphone. So, I am not aware of limitations (and it looks like there are some - like UIApplication sharedApplication is nil.

    Couple of thoughts:

    Backgrounding

    1) In the case if you plan to distribute through Cydia (meaning that applications will end up being on the system volume) you can use two undocument background modes:

    "continuos" (this one will keep running in the background) "unboundedTaskCompletion" (this one will have unlimited time, if you will do [UIApplication beginBackgroundTaskWithExpirationHandler]

    You can take a look at example Info.plist here, which uses continouse.

    2) There are other ways to get permanent background (which don't require even device to be jailbroken).

    As example, common method is to run silent audio on the loop. Here is example how to do this.

    Just be aware that this method won't be accept to App Store.

    3) In the case, if you device to go with route 1) or 2), you will have access to [UIApplication sharedApplication) to post local notifications

    4) You may be interested to take a look at the Backgrounder. I believe it implemented backgrounding capabilities for jailbroken devices. However, it may be outdate.

    Daemon problems with UIApplication

    5) Regarding problems with daemon. If you read carefully that article you will see

    The first thing to note is that it is not good to use the UIApplication class to start your daemon (it takes more memory than we need), so we are going to write our own main method.

    So, the code there was optimized for a memory. However, I am pretty sure that you can replace it with the common iOS application code:

    int main(int argc, char *argv[])
    {
        @autoreleasepool {
            return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        }
    }
    

    As result, I think you should have UIApplication singleton and should be able to post local notification.

    Yeah... It will eat up addition X kilobytes of memory, but who cares (if you aren't running 100 of such daemons)

提交回复
热议问题