[A] facebook share
This commit is contained in:
@@ -71,7 +71,7 @@ namespace tysdk.editor
|
||||
proj.AddCapability(target, PBXCapabilityType.SignInWithApple, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
proj.AddCapability(target, PBXCapabilityType.KeychainSharing, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
proj.AddCapability(target, PBXCapabilityType.PushNotifications, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
//proj.AddCapability(target, PBXCapabilityType.AssociatedDomains, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
proj.AddCapability(target, PBXCapabilityType.AssociatedDomains, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
}
|
||||
|
||||
private static void ProcessBuildSettings(PBXProject proj)
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.applesignin</key>
|
||||
<array>
|
||||
<string>Default</string>
|
||||
</array>
|
||||
<key>com.apple.developer.associated-domains</key>
|
||||
<array>
|
||||
<string>applinks:fishingtraveliae.onelink.me</string>
|
||||
</array>
|
||||
<key>com.apple.developer.usernotifications.communication</key>
|
||||
<true/>
|
||||
<key>keychain-access-groups</key>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package com.unity3d.player;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
@@ -13,6 +14,9 @@ import com.barton.log.builder.ParamsBuilder;
|
||||
import com.barton.log.ebarton.BaseUrl;
|
||||
import com.barton.log.ebarton.EventType;
|
||||
import com.barton.log.logapi.IGASDK;
|
||||
import com.facebook.share.model.ShareLinkContent;
|
||||
import com.facebook.share.widget.MessageDialog;
|
||||
import com.facebook.share.widget.ShareDialog;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.android.play.core.review.ReviewException;
|
||||
import com.google.android.play.core.review.ReviewInfo;
|
||||
@@ -38,6 +42,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SDKManager {
|
||||
|
||||
private final static Handler handler = new Handler(Looper.getMainLooper());
|
||||
@@ -390,6 +395,42 @@ public class SDKManager {
|
||||
});
|
||||
}
|
||||
|
||||
public static void FBShareLink(String title, String content, String url)
|
||||
{
|
||||
Log.e(TAG,"FBShareLink : " + title + " " + content + " " + url);
|
||||
|
||||
if (ShareDialog.canShow(ShareLinkContent.class)) {
|
||||
Activity activity = UnityPlayer.currentActivity;
|
||||
ShareDialog dialog = new ShareDialog(activity);
|
||||
ShareLinkContent linkContent = new ShareLinkContent.Builder()
|
||||
.setQuote(content)
|
||||
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
|
||||
.build();
|
||||
dialog.show(linkContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e(TAG, "FBShareDialog can not show");
|
||||
}
|
||||
}
|
||||
|
||||
public static void MessengerShareLink(String title, String content, String url)
|
||||
{
|
||||
Log.e(TAG,"MessengerShareLink : " + title + " " + content + " " + url);
|
||||
if (MessageDialog.canShow(ShareLinkContent.class)) {
|
||||
Activity activity = UnityPlayer.currentActivity;
|
||||
ShareLinkContent linkContent = new ShareLinkContent.Builder()
|
||||
.setQuote(content)
|
||||
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
|
||||
.build();
|
||||
MessageDialog.show(activity,linkContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e(TAG, "Messenger ShareDialog can not show");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import Foundation
|
||||
import FBSDKShareKit
|
||||
import Pods_UnityFramework
|
||||
|
||||
@objc public class FBShareHelper : NSObject{
|
||||
|
||||
@objc public func FBShare(title: String, content:String, link : String){
|
||||
guard let url = URL(string: link) else
|
||||
{
|
||||
NSLog("url faild")
|
||||
return
|
||||
}
|
||||
let vc = UnityFramework.getInstance().appController().rootViewController
|
||||
|
||||
let c = ShareLinkContent()
|
||||
c.quote = content
|
||||
c.contentURL = url
|
||||
|
||||
let dialog = ShareDialog(
|
||||
viewController: vc,
|
||||
content: c,
|
||||
delegate: FBShareHelperDelegate()
|
||||
)
|
||||
NSLog("show fb share dialog")
|
||||
// Recommended to validate before trying to display the dialog
|
||||
do {
|
||||
try dialog.validate()
|
||||
} catch {
|
||||
print("fbshare faild ! \(error)")
|
||||
}
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
@objc public func MFBShare(title: String, content:String, link : String){
|
||||
guard let url = URL(string: link) else
|
||||
{
|
||||
NSLog("url faild")
|
||||
return
|
||||
}
|
||||
|
||||
let c = ShareLinkContent()
|
||||
c.quote = content
|
||||
c.contentURL = url
|
||||
|
||||
let dialog = MessageDialog(content: c, delegate: FBShareHelperDelegate())
|
||||
|
||||
do {
|
||||
try dialog.validate()
|
||||
} catch {
|
||||
print("messenger share faild ! \(error)")
|
||||
}
|
||||
|
||||
if(dialog.canShow)
|
||||
{
|
||||
dialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
print("messenger share faild !")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FBShareHelperDelegate: SharingDelegate
|
||||
{
|
||||
public func sharer(_ sharer: any FBSDKShareKit.Sharing, didCompleteWithResults results: [String : Any]) {
|
||||
print("Share success \(results)")
|
||||
SendToUnity(success: true)
|
||||
}
|
||||
|
||||
public func sharer(_ sharer: any FBSDKShareKit.Sharing, didFailWithError error: any Error) {
|
||||
print("Share error \(error)")
|
||||
SendToUnity(success: false)
|
||||
}
|
||||
|
||||
public func sharerDidCancel(_ sharer: any FBSDKShareKit.Sharing) {
|
||||
print("Share cancel")
|
||||
SendToUnity(success: false)
|
||||
}
|
||||
|
||||
private func SendToUnity(success:Bool)
|
||||
{
|
||||
let message = success ? "0" : "1"
|
||||
UnityFramework.getInstance().sendMessageToGO(withName: "GameObje", functionName: "Func", message: message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74efa0262dac947a2a445362dc59c406
|
||||
guid: a4af00d7aeb9247deaac729b3df35036
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,13 +0,0 @@
|
||||
//
|
||||
// Hint.swift
|
||||
// UnityFramework
|
||||
//
|
||||
// Created by bamboo tech on 2024/8/2.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
struct SillyHint
|
||||
{
|
||||
var text = "Add This File for Complie, Do not delete";
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#import <GASDK/GAConstants.h>
|
||||
#import <GASDK/GASDK.h>
|
||||
#import "TYConfig.h"
|
||||
#import "UnityFramework/UnityFramework-Swift.h"
|
||||
|
||||
#define TOKEN_ERROR @"-8"
|
||||
extern "C" {
|
||||
@@ -351,5 +352,25 @@ extern "C" {
|
||||
|
||||
}
|
||||
|
||||
void FBShareLink(const char* title, const char* content, const char* url)
|
||||
{
|
||||
NSLog(@"TYSdkInterface FBShareLink");
|
||||
NSString *t = [[NSString alloc] initWithCString: title encoding:NSUTF8StringEncoding];
|
||||
NSString *c = [[NSString alloc] initWithCString: content encoding:NSUTF8StringEncoding];
|
||||
NSString *l = [[NSString alloc] initWithCString: url encoding:NSUTF8StringEncoding];
|
||||
|
||||
FBShareHelper *helper = [[FBShareHelper alloc] init];
|
||||
[helper FBShareWithTitle:t content:c link:l];
|
||||
}
|
||||
|
||||
void MessengerShareLink(const char* title, const char* content, const char* url)
|
||||
{
|
||||
NSLog(@"TYSdkInterface FBShareLink");
|
||||
NSString *t = [[NSString alloc] initWithCString: title encoding:NSUTF8StringEncoding];
|
||||
NSString *c = [[NSString alloc] initWithCString: content encoding:NSUTF8StringEncoding];
|
||||
NSString *l = [[NSString alloc] initWithCString: url encoding:NSUTF8StringEncoding];
|
||||
|
||||
FBShareHelper *helper = [[FBShareHelper alloc] init];
|
||||
[helper MFBShareWithTitle:t content:c link:l];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ namespace tysdk
|
||||
|
||||
public static void Review() { }
|
||||
|
||||
public static void FBShareLink(string title, string content, string url) { }
|
||||
public static void MessengerShareLink(string title, string content, string url) { }
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
private static string SDK_CLASS = "com.unity3d.player.SDKManager";
|
||||
@@ -205,6 +208,21 @@ namespace tysdk
|
||||
}
|
||||
}
|
||||
|
||||
public static void FBShareLink(string title, string content, string url)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("FBShareLink", title, content, url);
|
||||
}
|
||||
}
|
||||
|
||||
public static void MessengerShareLink(string title, string content, string url)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("MessengerShareLink", title, content, url);
|
||||
}
|
||||
}
|
||||
|
||||
#elif UNITY_IOS
|
||||
|
||||
@@ -367,6 +385,13 @@ namespace tysdk
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern int GetATT();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void FBShareLink(string title, string content, string url);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void MessengerShareLink(string title, string content, string url);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user