Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
pidan
/
FuSiLive
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
23d81783
authored
Jul 03, 2026
by
ludi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复兼容推特
parent
d0471c88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
247 additions
and
13 deletions
DevelopmentPods/FUSCommon/FUSCommon/Classes/Common/Other/FUSSocialShareManager.m
FuSiLive.xcodeproj/project.pbxproj
DevelopmentPods/FUSCommon/FUSCommon/Classes/Common/Other/FUSSocialShareManager.m
View file @
23d81783
...
...
@@ -324,25 +324,62 @@
self
.
shareSuccess
=
success
;
self
.
shareFailure
=
failure
;
if
(
viewController
==
nil
||
!
[[
UIApplication
sharedApplication
]
canOpenURL
:[
NSURL
URLWithString
:
@"twitter://"
]])
{
[
FUSDialogView
fus_showDialog
:[
NSString
fus_localString
:
@"请先安装Twitter"
]];
if
(
self
.
shareFailure
)
_shareFailure
();
UIViewController
*
presentingViewController
=
viewController
?:
[
UIViewController
fus_topViewController
];
if
(
presentingViewController
==
nil
)
{
if
(
self
.
shareFailure
)
{
self
.
shareFailure
();
}
self
.
shareSuccess
=
nil
;
self
.
shareFailure
=
nil
;
return
;
}
// 检查 Twitter 是否可用
if
(
!
[
SLComposeViewController
isAvailableForServiceType
:
@"com.apple.share.Twitter.post"
])
{
[
FUSDialogView
fus_showDialog
:[
NSString
fus_localString
:
@"请先安装Twitter"
]];
if
(
self
.
shareFailure
)
_shareFailure
();
self
.
shareSuccess
=
nil
;
self
.
shareFailure
=
nil
;
BOOL
canOpenTwitter
=
[[
UIApplication
sharedApplication
]
canOpenURL
:[
NSURL
URLWithString
:
@"twitter://"
]];
BOOL
isTwitterServiceAvailable
=
[
SLComposeViewController
isAvailableForServiceType
:
@"com.apple.share.Twitter.post"
];
if
(
!
canOpenTwitter
||
!
isTwitterServiceAvailable
)
{
[
self
fus_presentTwitterIntentWithContentURL
:
contentURL
content
:
content
image
:
image
shareType
:
shareType
completion
:^
(
BOOL
openSuccess
)
{
if
(
openSuccess
)
{
self
.
shareSuccess
=
nil
;
self
.
shareFailure
=
nil
;
return
;
}
[
self
fus_presentTwitterFallbackActivityViewControllerWithContentURL
:
contentURL
content
:
content
image
:
image
from
:
from
roomId
:
roomId
shareType
:
shareType
viewController
:
presentingViewController
];
}];
return
;
}
SLComposeViewController
*
twitterComposeVC
=
[
SLComposeViewController
composeViewControllerForServiceType
:
@"com.apple.share.Twitter.post"
];
if
(
twitterComposeVC
==
nil
)
{
[
self
fus_presentTwitterIntentWithContentURL
:
contentURL
content
:
content
image
:
image
shareType
:
shareType
completion
:^
(
BOOL
openSuccess
)
{
if
(
openSuccess
)
{
self
.
shareSuccess
=
nil
;
self
.
shareFailure
=
nil
;
return
;
}
[
self
fus_presentTwitterFallbackActivityViewControllerWithContentURL
:
contentURL
content
:
content
image
:
image
from
:
from
roomId
:
roomId
shareType
:
shareType
viewController
:
presentingViewController
];
}];
return
;
}
switch
(
shareType
)
{
case
FUSShareTypeText
:{
...
...
@@ -391,7 +428,7 @@
};
twitterComposeVC
.
modalPresentationStyle
=
UIModalPresentationPageSheet
;
[
[
UIViewController
fus_topViewController
]
presentViewController
:
twitterComposeVC
animated
:
YES
completion
:^
{
[
presentingViewController
presentViewController
:
twitterComposeVC
animated
:
YES
completion
:^
{
}];
...
...
@@ -486,6 +523,203 @@
// }
}
/**
Twitter 分享不可用时,先尝试跳转到 X Web Intent
@param contentURL 分享链接
@param content 分享文案
@param image 分享图片
@param shareType 分享类型
@param completion 跳转完成回调
*/
-
(
void
)
fus_presentTwitterIntentWithContentURL
:
(
NSString
*
)
contentURL
content
:
(
NSString
*
)
content
image
:
(
UIImage
*
)
image
shareType
:
(
FUSShareType
)
shareType
completion
:
(
void
(
^
)(
BOOL
openSuccess
))
completion
{
NSString
*
text
=
content
.
length
?
content
:
nil
;
NSString
*
urlString
=
contentURL
.
length
?
contentURL
:
nil
;
switch
(
shareType
)
{
case
FUSShareTypeImage
:
{
if
(
urlString
.
length
==
0
&&
text
.
length
==
0
&&
image
!=
nil
)
{
if
(
completion
)
{
completion
(
NO
);
}
return
;
}
}
break
;
case
FUSShareTypeWebUrl
:
{
}
break
;
case
FUSShareTypeText
:
case
FUSShareTypeDefault
:
case
FUSShareTypeImageWithText
:
{
}
break
;
default
:
break
;
}
if
(
text
.
length
==
0
&&
urlString
.
length
==
0
)
{
if
(
completion
)
{
completion
(
NO
);
}
return
;
}
NSURLComponents
*
components
=
[[
NSURLComponents
alloc
]
init
];
components
.
scheme
=
@"https"
;
components
.
host
=
@"x.com"
;
components
.
path
=
@"/intent/tweet"
;
NSMutableArray
<
NSURLQueryItem
*>
*
queryItems
=
[
NSMutableArray
array
];
if
(
text
.
length
)
{
[
queryItems
addObject
:[
NSURLQueryItem
queryItemWithName
:
@"text"
value
:
text
]];
}
if
(
urlString
.
length
)
{
[
queryItems
addObject
:[
NSURLQueryItem
queryItemWithName
:
@"url"
value
:
urlString
]];
}
components
.
queryItems
=
queryItems
;
NSURL
*
intentURL
=
components
.
URL
;
if
(
intentURL
==
nil
)
{
if
(
completion
)
{
completion
(
NO
);
}
return
;
}
[[
UIApplication
sharedApplication
]
openURL
:
intentURL
options
:@{}
completionHandler
:^
(
BOOL
success
)
{
if
(
completion
)
{
completion
(
success
);
}
}];
}
/**
Twitter 分享不可用且 X Web Intent 无法跳转时,降级为系统分享面板
@param contentURL 分享链接
@param content 分享文案
@param image 分享图片
@param from 分享来源
@param roomId 房间 ID
@param shareType 分享类型
@param viewController 用于弹出系统分享面板的控制器
*/
-
(
void
)
fus_presentTwitterFallbackActivityViewControllerWithContentURL
:
(
NSString
*
)
contentURL
content
:
(
NSString
*
)
content
image
:
(
UIImage
*
)
image
from
:
(
FUSFrom
)
from
roomId
:
(
NSString
*
)
roomId
shareType
:
(
FUSShareType
)
shareType
viewController
:
(
UIViewController
*
)
viewController
{
NSMutableArray
*
activityItems
=
[
NSMutableArray
array
];
NSURL
*
shareURL
=
contentURL
.
length
?
[
NSURL
URLWithString
:
contentURL
]
:
nil
;
switch
(
shareType
)
{
case
FUSShareTypeText
:
{
if
(
content
.
length
)
{
[
activityItems
addObject
:
content
];
}
}
break
;
case
FUSShareTypeImage
:
{
if
(
image
!=
nil
)
{
[
activityItems
addObject
:
image
];
}
}
break
;
case
FUSShareTypeWebUrl
:
{
if
(
content
.
length
)
{
[
activityItems
addObject
:
content
];
}
if
(
shareURL
!=
nil
)
{
[
activityItems
addObject
:
shareURL
];
}
}
break
;
case
FUSShareTypeDefault
:
case
FUSShareTypeImageWithText
:
{
if
(
image
!=
nil
)
{
[
activityItems
addObject
:
image
];
}
if
(
content
.
length
)
{
[
activityItems
addObject
:
content
];
}
}
break
;
default
:
break
;
}
if
(
activityItems
.
count
==
0
)
{
if
(
content
.
length
)
{
[
activityItems
addObject
:
content
];
}
if
(
shareURL
!=
nil
)
{
[
activityItems
addObject
:
shareURL
];
}
if
(
image
!=
nil
)
{
[
activityItems
addObject
:
image
];
}
}
if
(
activityItems
.
count
==
0
)
{
[
FUSDialogView
fus_showDialog
:[
NSString
fus_versionLocalString
:
@"暂无可分享内容"
]];
if
(
self
.
shareFailure
)
{
self
.
shareFailure
();
}
self
.
shareSuccess
=
nil
;
self
.
shareFailure
=
nil
;
return
;
}
__weak
typeof
(
self
)
weakSelf
=
self
;
UIActivityViewController
*
activityViewController
=
[[
UIActivityViewController
alloc
]
initWithActivityItems
:
activityItems
applicationActivities
:
nil
];
activityViewController
.
completionWithItemsHandler
=
^
(
UIActivityType
_Nullable
activityType
,
BOOL
completed
,
NSArray
*
_Nullable
returnedItems
,
NSError
*
_Nullable
activityError
)
{
if
(
activityError
!=
nil
)
{
[
FUSDialogView
fus_showDialog
:[
NSString
fus_localString
:
@"分享失败"
]];
if
(
weakSelf
.
shareFailure
)
{
weakSelf
.
shareFailure
();
}
}
else
if
(
!
completed
)
{
[
FUSDialogView
fus_showDialog
:[
NSString
fus_localString
:
@"分享取消"
]];
if
(
weakSelf
.
shareFailure
)
{
weakSelf
.
shareFailure
();
}
}
else
{
NSString
*
version
=
[[
FUSDeviceHelper
getAppVersionNumber
]
description
];
[
FUSCommonHttpRequest
fus_socialShareStatisticWithMode
:
weakSelf
.
mode
modeType
:
2
version
:
version
from
:
from
roomId
:
roomId
];
[
FUSDialogView
fus_showDialog
:[
NSString
fus_localString
:
@"分享成功"
]];
if
(
weakSelf
.
shareSuccess
)
{
weakSelf
.
shareSuccess
();
}
}
weakSelf
.
shareSuccess
=
nil
;
weakSelf
.
shareFailure
=
nil
;
};
UIPopoverPresentationController
*
popoverController
=
activityViewController
.
popoverPresentationController
;
if
(
popoverController
!=
nil
)
{
popoverController
.
sourceView
=
viewController
.
view
;
popoverController
.
sourceRect
=
CGRectMake
(
CGRectGetMidX
(
viewController
.
view
.
bounds
),
CGRectGetMidY
(
viewController
.
view
.
bounds
),
1
.
0
,
1
.
0
);
}
[
viewController
presentViewController
:
activityViewController
animated
:
YES
completion
:
nil
];
}
/*
line 分享
*/
...
...
FuSiLive.xcodeproj/project.pbxproj
View file @
23d81783
...
...
@@ -691,7 +691,7 @@
CLANG_CXX_LANGUAGE_STANDARD
=
"gnu++17"
;
CODE_SIGN_ENTITLEMENTS
=
FuSiLive/FuSiLive.entitlements
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
2026054
7
;
CURRENT_PROJECT_VERSION
=
2026054
8
;
DEFINES_MODULE
=
YES
;
DEVELOPMENT_TEAM
=
6GG26BHUMC
;
ENABLE_ON_DEMAND_RESOURCES
=
NO
;
...
...
@@ -956,7 +956,7 @@
CLANG_CXX_LANGUAGE_STANDARD
=
"gnu++17"
;
CODE_SIGN_ENTITLEMENTS
=
FuSiLive/FuSiLive.entitlements
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
2026054
7
;
CURRENT_PROJECT_VERSION
=
2026054
8
;
DEFINES_MODULE
=
YES
;
DEVELOPMENT_TEAM
=
6GG26BHUMC
;
ENABLE_ON_DEMAND_RESOURCES
=
NO
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment