ios - Can I test local notifications on the WatchOS 2 Simulator? -
i googling lot find out way check local notifications on watchos simulator because don't have iwatch. right have implemented local notification due reason notification shown on iphone simulator not on iwatch (watchos 2) simulator.
i have added following code in applicationdidfinishlaunchingwithoptions:
uimutableusernotificationaction *action1; action1 = [[uimutableusernotificationaction alloc] init]; [action1 setactivationmode:uiusernotificationactivationmodebackground]; [action1 settitle:@"action 1"]; [action1 setidentifier:kaction1]; [action1 setdestructive:no]; [action1 setauthenticationrequired:no]; uimutableusernotificationaction *action2; action2 = [[uimutableusernotificationaction alloc] init]; [action2 setactivationmode:uiusernotificationactivationmodebackground]; [action2 settitle:@"action 2"]; [action2 setidentifier:kaction2]; [action2 setdestructive:no]; [action2 setauthenticationrequired:no]; uimutableusernotificationcategory *actioncategory; actioncategory = [[uimutableusernotificationcategory alloc] init]; [actioncategory setidentifier:kaction3]; [actioncategory setactions:@[action1, action2] forcontext:uiusernotificationactioncontextdefault]; nsset *categories = [nsset setwithobject:actioncategory]; uiusernotificationtype types = (uiusernotificationtypealert| uiusernotificationtypesound| uiusernotificationtypebadge); uiusernotificationsettings *settings; settings = [uiusernotificationsettings settingsfortypes:types categories:categories]; [[uiapplication sharedapplication] registerusernotificationsettings:settings]; have been able notifications watchos local notifications in simulator?
run watch app on simulator, iphone simulator schedule notification , lock iphone simulator screen, keep watch simulator active, in case when notification triggered , delivered on watch simulator. same case when test on actual devices.
Comments
Post a Comment