"Reprint from Friend Alliance message push iOS document" register push in Appdelegate

Source: Internet
Author: User

1.2 Basic Function Integration Guide

Tips
Please create an app in the Friend Alliance's message push management background to get Appkey and Appsecret

  • Import SDK

    • Download Umessage_sdk_all_x.x.x.zip and Unzip
    • Import Plugins

    Required SDK folders:UMessage_Sdk_x.x.x
    In your project directory structure, right-click Add->Existing Files… to select this folder. Or drag this folder into the Xcode project directory structure, tick the popup screen Copy items into destination group‘s folder(if needed) , and make sure to Add To Targets tick the appropriate target.

  • Configuration (optional)

    • The SDK uses ARC to manage memory, non-ARC projects are also default support, if you encounter problems, please contact us
    • If you are using -all_load , you may need to add libz a library:
      TARGETS--and-- Build Phases Link Binary With Libraries +libz.dylib

    Description
    SDK supports iOS 4.3+

  • Add code

  • Defining macros

    #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO (v) ([[[Uidevice Currentdevice] systemversion] compare:v options: Nsnumericsearch]! = nsorderedascending)

    #define IOS8 system_version_greater_than_or_equal_to (@ "8.0")


  • Open *AppDelegate.m , and then follow these steps to integrate:

    • didFinishLaunchingWithOptionsThe settings in:
- (BOOL) Application: (UIApplication *) Application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions{Set AppKey and Appsecret [umessage Startwithappkey:@ "Your Appkey" launchoptions:launchoptions];#if __iphone_os_version_max_allowed >= _iphone80_
IfIOS8)
{
Register remotenotification types (IOS 8.0 and later)
Uimutableusernotificationaction *action1 = [[Uimutableusernotificationaction alloc] init];
Action1.identifier = @"Action1_identifier";
[Email protected]"Accept";
Action1.activationmode = uiusernotificationactivationmodeforeground;//Start the program when clicked

Uimutableusernotificationaction *action2 = [[Uimutableusernotificationaction alloc] init]; Second button
Action2.identifier = @"Action2_identifier";
[Email protected]"Reject";
Action2.activationmode = uiusernotificationactivationmodebackground;//When clicked does not start the program, in the background processing
action2.authenticationrequired = yes;//need to be unlocked for processing if Action.activationmode = Uiusernotificationactivationmodeforeground; the attribute is ignored;
Action2.destructive = YES;

Uimutableusernotificationcategory *categorys = [[Uimutableusernotificationcategory alloc] init];
Categorys.identifier = @"Category1";//The only indication of this set of actions
[Categorys Setactions:@[action1,action2] Forcontext: (Uiusernotificationactioncontextdefault)];

Uiusernotificationsettings *usersettings = [uiusernotificationsettings settingsfortypes: uiusernotificationtypebadge| uiusernotificationtypesound| Uiusernotificationtypealert
Categories:[nsset Setwithobject:categorys]];
[Umessage registerremotenotificationandusernotificationsettings:usersettings];

} else{
Register remotenotification types (below IOS 8.0)
[Umessage Registerforremotenotificationtypes:uiremotenotificationtypebadge
| Uiremotenotificationtypesound
| Uiremotenotificationtypealert];
}
#else

Register remotenotification types (below IOS 8.0)
[umessage Registerforremotenotificationtypes:uiremotenotificationtypebadge
Span class= "Hljs-preprocessor" > | Uiremotenotificationtypesound
| Uiremotenotificationtypealert];

#endif
//for log
[Umessage Setlogenabled:yes];

return YES;
} /span>
    • didRegisterForRemoteNotificationsWithDeviceTokenSet in
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{ [UMessage registerDeviceToken:deviceToken]; }
    • didReceiveRemoteNotificationSet in
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ [UMessage didReceiveRemoteNotification:userInfo];}

Description
If you want to turn off push, please use[UMessage unregisterForRemoteNotifications]

At this point, the integration of the message push basic functionality has been completed.

"Reprint from Friend Alliance message push iOS document" register push in Appdelegate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.