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