Skip to content

Device Sharing

Feature Description

You can share your devices to other users through the device sharing feature so that the sharing recipients can control your devices.

See QuecDeviceModel Definition in Device Management.

objc
#import <QuecDeviceKit/QuecDeviceKit.h>
/// Initialization.
[QuecDeviceShareService sharedInstance]

Device Sharing

Query Device Information by Share Code

API

Query the device information by a share code.

objc
- (void)getDeviceInfoByShareCode:(NSString *)shareCode
                          success:(void(^)(QuecDeviceModel *deviceModel))success
                          failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
shareCodeYShare code.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceShareService.sharedInstance getDeviceInfoByShareCode:@"shareCode" success:^(QuecDeviceModel *deviceModel) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Change Shared Device Name

API

Change the name of the shared device.

objc
- (void)updateDeviceNameByShareUserWithDeviceName:(NSString *)deviceName
                                          shareCode:(NSString *)shareCode
                                            success:(QuecVoidBlock)success
                                            failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceNameYDevice name.
shareCodeYShare code.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceShareService.sharedInstance updateDeviceNameByShareUserWithDeviceName:@"deviceName" shareCode:@"shareCode" success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Get Device Shared Recipient List

API

Get the recipient list to whom the group is shared.

objc
- (void)getDeviceShareUserListWithDeviceKey:(NSString *)deviceKey
                                   productKey:(NSString *)productKey
                                      success:(void(^)(NSArray<QuecShareUserModel *> *list))success
                                      failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceKeyYDeviceKey.
productKeyYProductKey.
successNCallback function of successful request.
failureNCallback function of failed request.

QuecShareUserModel Definition

FieldTypeDescription
shareInfoQuecShareUserShareInfoModelSharing information.
userInfoQuecShareUserInfoModelUser information.

QuecShareUserShareInfoModel Definition

FieldTypeDescription
acceptTimeNSStringTime to accept the sharing.
acceptingExpireAtNSStringExpiration time of accepting the sharing.
coverMarkNSIntegerOverwrite flag.
deviceNameNSStringDevice name.
dkNSStringDeviceKey.
ownerUidNSStringOwner ID.
pkNSStringProductKey.
shareCodeNSStringShare code.
shareIdNSStringSharing ID.
shareStatusNSIntegerSharing status.
shareTimeNSStringTime to create the sharing.
shareUidNSStringUser ID of the share recipient.
sharingExpireAtNSStringExpiration time of the sharing after the sharing is accepted.
updateTimeNSStringUpdate time.

QuecShareUserInfoModel Definition

FieldTypeDescription
addressNSStringAddress.
emailNSStringEmail address.
headimgNSStringProfile.
lastLoginTimeNSStringLast login time.
nikeNameNSStringNickname.
phoneNSStringPhone number.
registerTimeNSStringRegistration time.
sexNSStringGender.
uidNSStringUser ID.
userDomainNSStringUser domain.
userTypeNSIntegerUser source.
wchartIdNSStringWechat ID.
wchartNameNSStringWeChat name.

Example

objc
[QuecDeviceShareService.sharedInstance getDeviceShareUserListWithDeviceKey:@"deviceKey" productKey:@"productKey" success:^(NSArray<QuecShareUserModel *> * _Nonnull list) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Initiator Cancel Sharing

API

The share initiator cancels the sharing.

objc
- (void)unShareDeviceByOwnerWithShareCode:(NSString *)shareCode
                                    success:(QuecVoidBlock)success
                                    failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
shareCodeYShare code.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceShareService.sharedInstance unShareDeviceByOwnerWithShareCode:@"shareCode" success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Recipient Cancel Sharing

API

The share recipient cancels the sharing.

objc
- (void)unShareDeviceByShareUserWithShareCode:(NSString *)shareCode
                                        success:(QuecVoidBlock)success
                                        failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
shareCodeYShare code.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceShareService.sharedInstance unShareDeviceByShareUserWithShareCode:@"shareCode" success:^{
    /// Next Action
} failure::^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Accept Sharing

API

The share recipient accepts the sharing.

objc
- (void)acceptShareByShareUserWithShareCode:(NSString *)shareCode
                                   deviceName:(NSString *)deviceName
                                      success:(QuecVoidBlock)success
                                      failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
shareCodeYShare code.
deviceNameYDevice name.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceShareService.sharedInstance acceptShareByShareUserWithShareCode:@"shareCode" deviceName:@"deviceName" success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Set Device Sharing Information

API

Set the sharing information of the group.

objc
- (void)setShareInfoByOwnerWithDeviceKey:(NSString *)deviceKey
                                productKey:(NSString *)productKey
                      acceptingExpireTime:(NSInteger)acceptingExpireTime
                                 coverMark:(NSInteger)coverMark
                     isSharingAlwaysValid:(BOOL)isSharingAlwaysValid
                        sharingExpireTime:(NSInteger)sharingExpireTime
                                   success:(void(^)(NSString *shareCode))success
                                   failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
deviceKeyYDeviceKey.
productKeyYProductKey.
acceptingExpireTimeYExpiration time of the shared QR code, in milliseconds. This share will expire if it is not used before the expiration time.
coverMarkYOverwrite flag. Default value: 1.
1 Directly overwrite the previous valid share (overwrite the existing sharing code)
2 Add a new share directly, allowing multiple shares to coexist
3 Overwrite the previous share only when the sharing time is extended.
isSharingAlwaysValidNWhether the device sharing is permanently valid.
sharingExpireTimeNExpiration time of the device usage, in milliseconds. The shared device can be used by the recipient before the expiration time. This parameter is invalid when isSharingAlwaysValid = YES.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecDeviceShareService.sharedInstance setShareInfoByOwnerWithDeviceKey:@"deviceKey"
                                                                         productKey:@"productKey"
                                                                acceptingExpireTime:expireTimeTS
                                                                          coverMark:1
                                                               isSharingAlwaysValid:YES
                                                                  sharingExpireTime:0 success:^(NSString * _Nonnull shareCode) {
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];