ios本地推送互動

2022-08-03 07:54:11 字數 2415 閱讀 2951

**如下:

// uimutableusernotificationaction *action1=[uimutableusernotificationaction new

]; action1.identifier=@"

action_1";

action1.title=@"

title";

action1.activationmode=uiusernotificationactivationmodeforeground;

action1.authenticationrequired=yes;

action1.destructive=no;

uimutableusernotificationaction *action2=[uimutableusernotificationaction new

]; action2.identifier=@"

action_2";

action2.title=@"

title2";

action2.authenticationrequired=no;

action2.activationmode=uiusernotificationactivationmodebackground;

action2.destructive=yes;

uimutableusernotificationaction *action3=[uimutableusernotificationaction new

]; action3.identifier=@"

action_3";

action3.title=@"

title3";

action3.activationmode=uiusernotificationactivationmodebackground;

action3.authenticationrequired=no;

action3.destructive=no;;

uimutableusernotificationaction *action4=[uimutableusernotificationaction new

]; action4.identifier=@"

action_4";

action4.title=@"

titile4";

action4.activationmode=uiusernotificationactivationmodebackground;

action4.authenticationrequired=no;

action4.destructive=no;

uimutableusernotificationcategory *category=[uimutableusernotificationcategory new

]; category.identifier=@"

category";

[category setactions:@[action1,action2,action3,action4] forcontext:uiusernotificationactioncontextdefault];

nsset *categories=[nsset setwithobject:category];

uiusernotificationsettings *setting=[uiusernotificationsettings settingsfortypes:uiusernotificationtypealert|uiusernotificationtypebadge|uiusernotificationtypesound categories:categories];

return

yes;}這

調到前台執行,設定為前台執行就需要賦值為yes;authenticationrequired是只當裝置屬於鎖定狀態時候,是否要求使用者先解

鎖;destructive是標識特別重要的按鈕,操作他可能帶來一定的影響,例如刪除資料。

if ([identifier isequaltostring:@"

action_2

"])

if ([identifier isequaltostring:@"

action_3

"])

if ([identifier isequaltostring:@"

aaction_4

"])

}completionhandler();

//必寫

}最後在viewdidload寫(圖方便)

- (void

)viewdidload

謝謝!初次寫,不足之處請諒解!!!

ios本地推送

第一步 建立本地推送 建立乙個本地推送 uilocalnotification notification uilocalnotification alloc init autorelease 設定10秒之後 nsdate pushdate nsdate datewithtimeintervalsin...

iOS 本地推送

通知完一定要取消,ios最多允許最近本地通知數量是64個,超過限制的本地通知將被忽略。第一步 建立本地推送 建立乙個本地推送 uilocalnotification notification uilocalnotification alloc init autorelease 設定10秒之後 nsd...

iOS本地推送

第一步 建立本地推送 建立乙個本地推送 uilocalnotification notification uilocalnotification alloc init autorelease 設定10秒之後 nsdate pushdate nsdate datewithtimeintervalsin...