ios - Update Application Badge With WatchKit and Widget (Today Extension)? -
in app update application badge after events using code works:
[[uiapplication sharedapplication] schedulelocalnotification:localnotification];
however [uiapplication sharedapplication] cannot called watchkit or widget. there way widget update application badge other way?
i tried using background fetch this. badge gets updated when explicitly "simulate background fetch" xcode. on actual device background fetch never gets called? idea command call background fetch?
- (void)application:(uiapplication *)application performfetchwithcompletionhandler:(void (^)(uibackgroundfetchresult))completionhandler { // background fetch [[globalnotifications sharedinstance] setapplicationbadge]; completionhandler(uibackgroundfetchresultnewdata); }
thanks insight on this.
you correct schedulelocalnotification can called ios main app. watch app, if using watchos 2 can tell ios app schedule notification in background using watchconnectivity. recommend using wcsession method sendmessage schedule notification.
in watchos 1, can use openparentapplication method so:
// on watch extension [interfacecontroller openparentapplication:request reply:^(nsdictionary *replyinfo, nserror *error) { // handle response phone }]; // in appdelegate of phone: - (void)application:(uiapplication *)application handlewatchkitextensionrequest:(nsdictionary *)userinfo reply:(void (^)(nsdictionary *))reply // todo: schedule notification here... nsdictionary *response = // custom response reply(response); }
i not aware of way different kind of app extension (like today extension) kind of communication parent app.
Comments
Post a Comment