### Android: Start Mini Program with Arguments
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Example of launching a UniMP mini program on Android and passing custom arguments.
```java
// 启动小程序并传入参数 "Hello uni microprogram"
try {
JSONObject arguments = new JSONObject();
arguments.put("MSG","Hello uni microprogram");
DCUniMPSDK.getInstance().startApp(context, "__UNI__04E3A11", arguments);
} catch (Exception e) {
e.printStackTrace();
}
```
--------------------------------
### iOS: Start Mini Program with Arguments
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Example of launching a UniMP mini program on iOS and passing custom arguments.
```objective-c
// 启动小程序并传入参数
NSDictionary *arguments = @{@"value":@"Hello uni microprogram"};
[DCUniMPSDKEngine openApp:appid arguments:arguments];
```
--------------------------------
### Android: Start Mini Program to Specific Page
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Example of launching a UniMP mini program on Android and directly opening a specified page.
```java
// 启动直达页面
DCUniMPSDK.getInstance().startApp(context,"__UNI__04E3A11", "pages/component/view/view?action=redirect");
```
--------------------------------
### iOS: Start Mini Program to Specific Page
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Example of launching a UniMP mini program on iOS and directly opening a specified page with parameters.
```objective-c
// 启动直达页面
NSString *pagePath = @"pages/component/view/view?action=redirect";
[DCUniMPSDKEngine openApp:k_AppId arguments:nil redirectPath:pagePaht];
```
--------------------------------
### Package JSON Parameters Example
Source: https://github.com/dcloudio/native-docs/blob/master/docs/NativePlugin/course/package.md
Example of configuring 'appid_android' and 'appkey_android' parameters for a plugin. These configurations will be added to AndroidManifest.xml's meta-data node during cloud packaging.
```json
"parameters": {
"appid_android": {
"des": "Android平台的appid",
"key": "HelloPlugin_appid"
},
"appkey_android": {
"des": "Android平台的appkey",
"key": "HelloPlugin_appkey"
}
}
```
--------------------------------
### Passing Arguments to Mini-program (iOS)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Example demonstrating how to pass arguments when launching a UniMP application on iOS.
```APIDOC
## iOS Example - Passing Arguments
### Description
This example shows how to pass a dictionary of arguments when opening a UniMP app on iOS.
### Code
```Objective-C
NSDictionary *arguments = @{@"value":@"Hello uni microprogram"};
[DCUniMPSDKEngine openApp:appid arguments:arguments];
```
```
--------------------------------
### Passing Arguments to Mini-program (Android)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Example demonstrating how to pass arguments when launching a UniMP application on Android.
```APIDOC
## Android Example - Passing Arguments
### Description
This example shows how to construct a JSONObject and pass it as arguments when starting a UniMP app on Android.
### Code
```JAVA
try {
JSONObject arguments = new JSONObject();
arguments.put("MSG","Hello uni microprogram");
DCUniMPSDK.getInstance().startApp(context, "__UNI__04E3A11", arguments);
} catch (Exception e) {
e.printStackTrace();
}
```
```
--------------------------------
### Check and Install UniMP Resources
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/ios.md
This method checks if mini-program resources exist and installs them if not. It's crucial for ensuring mini-programs run correctly. Note that this only checks the runtime path; built-in wgt versions must also be managed.
```objective-c
/// 检查运行目录是否存在应用资源,不存在将应用资源部署到运行目录
- (void)checkUniMPResource:(NSString *)appid {
#warning 注意:isExistsUniMP: 方法判断的仅是运行路径中是否有对应的应用资源,宿主还需要做好内置wgt版本的管理,如果更新了内置的wgt也应该执行 installUniMPResourceWithAppid 方法应用最新的资源
if (![DCUniMPSDKEngine isExistsUniMP:appid]) {
// 读取导入到工程中的wgt应用资源
NSString *appResourcePath = [[NSBundle mainBundle] pathForResource:appid ofType:@"wgt"];
if (!appResourcePath) {
NSLog(@"资源路径不正确,请检查");
return;
}
// 将应用资源部署到运行路径中
NSError *error;
if ([DCUniMPSDKEngine installUniMPResourceWithAppid:appid resourceFilePath:appResourcePath password:nil error:&error]) {
NSLog(@"小程序 %@ 应用资源文件部署成功,版本信息:%@",appid,[DCUniMPSDKEngine getUniMPVersionInfoWithAppid:appid]);
} else {
NSLog(@"小程序 %@ 应用资源部署失败: %@",appid,error);
}
} else {
NSLog(@"已存在小程序 %@ 应用资源,版本信息:%@",appid,[DCUniMPSDKEngine getUniMPVersionInfoWithAppid:appid]);
}
}
```
--------------------------------
### Android: Start Mini Program API
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
This is the Java method signature for starting a UniMP mini program on Android, including context, app ID, splash screen, redirect path, and arguments.
```java
// 启动小程序
DCUniMPSDK.getInstance().startApp(context, appid, splashClass, redirectPath, arguments)
```
--------------------------------
### Podfile Example for UniMP SDK
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/ios.md
This is a sample Podfile configuration for integrating the UniMP SDK and its various modules into an Xcode project. Ensure to uncomment the specific subspecs you need for your project.
```shell
use_frameworks! ## Swift项目需要添加
target 'HelloUniMPDemo' do
pod 'unimp', :subspecs => [
'Core', ##核心库(必需)
# 'Accelerometer', ##加速度传感器
# 'Contacts', ##通讯录
# 'Audio', ##音频
# 'Camera&Gallery', ##相机&相册
# 'File', ##文件
# 'Video', ##视频播放
# 'LivePusher', ##直播推流
# 'NativeJS', ##JS Reflection call Native
# 'Orientation', ##设备方向
# 'Message', ##邮件消息
# 'Zip', ##压缩
# 'Proximity', ##距离传感器
# 'Sqlite', ##数据库
# 'Barcode', ##扫码
# 'XMLHttpRequest', ##网络请求
# 'Fingerprint', ##指纹识别
# 'FaceId', ##人脸识别
# 'Log', ##打印Console.log日志,发布时可移除
# 'IBeacon', ##低功耗蓝牙
# 'BlueTooth', ##蓝牙
# 'Speech-Baidu', ##语音识别-百度
# 'Statistic-Umeng', ##友盟统计
# ##定位模块(百度高德不能同时引用)
# 'Geolocation', ##系统定位
# 'Geolocation-Gaode', ##高德定位
# 'Geolocation-Baidu', ##百度定位
# ##地图(二选一)
# 'Map-Gaode', ##高德地图
# 'Map-Baidu', ##百度地图
# ##支付
# 'Payment-IAP', ##苹果内购
# 'Payment-AliPay', ##支付宝支付
# 'Payment-Wechat', ##微信支付-同时使用微信分享或登录,必需使用包含支付的依赖库
# 'Payment-Paypal', ##Paypal支付 iOS13+
# 'Payment-Stripe', ##stripe支付 iOS13+
# ##分享
# 'Share-Wechat', ##微信分享-包含支付
# 'Share-Wechat-Nopay', ##微信分享-不包含支付
# 'Share-QQ', ##QQ分享
# 'Share-Sina', ##新浪微博分享
# ##登录
# 'Oauth-Apple', ##苹果登录
# 'Oauth-QQ', ##QQ登录
# 'Oauth-Wechat', ##微信登录-包含支付
# 'Oauth-Wechat-Nopay', ##微信登录-不包含支付
# 'Oauth-Sina', ##新浪微博登录
# 'Oauth-Google', ##Google登录
# 'Oauth-Facebook', ##Facebook登录 iOS12+
]
# pod 'FBSDKLoginKit','16.2.1' ##使用Oauth-Facebook 时需添加该库
# pod 'Stripe','23.18.2' ##使用Payment-Stripe 时需添加该库
# pod 'PayPalCheckout','1.2.0' ##使用Payment-Paypal 时需添加该库
end
```
--------------------------------
### UniMP: Get Arguments in Mini Program
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
JavaScript code to retrieve arguments passed from the host application when a UniMP mini program starts.
```javascript
var arguments = plus.runtime.arguments;
```
--------------------------------
### Launching a Specific Page (Android)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Example for launching a UniMP application directly to a specified page on Android.
```APIDOC
## Android Example - Launching Specific Page
### Description
This example shows how to provide a page path to the `startApp` method to open a specific page directly when launching a UniMP app on Android.
### Code
```JAVA
DCUniMPSDK.getInstance().startApp(context,"__UNI__04E3A11", "pages/component/view/view?action=redirect");
```
```
--------------------------------
### Android Platform - Start App
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Initiates a UniMP application on Android, allowing for context, app ID, splash screen customization, redirect path, and arguments.
```APIDOC
## DCUniMPSDK.getInstance().startApp(context, appid, splashClass, redirectPath, arguments)
### Description
Starts a UniMP application on Android, providing context, app ID, an optional splash screen class, a redirect path, and arguments.
### Method
`startApp`
### Parameters
#### Path Parameters
- **context** (Context) - Required - The application context.
- **appid** (String) - Required - The appid of the mini-program.
- **splashClass** (IDCUniMPAppSplashView) - Optional - A custom splash screen interface class.
- **redirectPath** (String) - Optional - The path of the page to open directly after startup.
- **arguments** (JSONObject) - Optional - Parameters to pass to the mini-program upon startup.
```
--------------------------------
### Getui One-Click Login Build.gradle Configuration
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/androidModuleConfig/oauth.md
Configure manifest placeholders for Getui AppID, GY App ID, and install channel in the app's build.gradle file. GT_INSTALL_CHANNEL should be set to 'HBuilder'.
```gradle
android {
defaultConfig {
manifestPlaceholders = [
"GETUI_APPID" : "%GETUI_APPID%",
"GY_APP_ID" : "%GY_APP_ID%",
"GT_INSTALL_CHANNEL":"HBuilder",
// (GT_INSTALL_CHANNEL 固定值 "HBuilder")
]
}
}
```
--------------------------------
### Launching a Specific Page (iOS)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Example for launching a UniMP application directly to a specified page on iOS.
```APIDOC
## iOS Example - Launching Specific Page
### Description
This example demonstrates how to specify a page path to open directly upon launching a UniMP app on iOS.
### Code
```Objective-C
NSString *pagePath = @"pages/component/view/view?action=redirect";
[DCUniMPSDKEngine openApp:k_AppId arguments:nil redirectPath:pagePaht];
```
```
--------------------------------
### Start Activity for Result
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Extension/android.md
Starts a native Android Activity and expects a result back. Uses startActivityForResult with a defined request code.
```JAVA
@UniJSMethod (uiThread = true)
public void gotoNativePage(){
if(mUniSDKInstance != null && mUniSDKInstance.getContext() instanceof Activity) {
Intent intent = new Intent(mUniSDKInstance.getContext(), NativePageActivity.class);
((Activity)mUniSDKInstance.getContext()).startActivityForResult(intent, REQUEST_CODE);
}
}
```
--------------------------------
### Java @UniJSMethod Example (UI Thread)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Extension/android.md
Example of a JavaScript method within a UniModule that executes on the UI thread. It accepts JSON options and a callback for asynchronous responses.
```java
//run ui thread
@UniJSMethod(uiThread = true)
public void testAsyncFunc(JSONObject options, UniJSCallback callback) {
Log.e(TAG, "testAsyncFunc--"+options);
if(callback != null) {
JSONObject data = new JSONObject();
data.put("code", "success");
callback.invoke(data);
}
}
```
--------------------------------
### Push Module Configuration in feature.plist
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/iOSModuleConfig/push.md
Configure the Push module in your project's feature.plist file. Ensure the settings match the provided example for autostart, base class, and server configuration.
```xml
Push
autostart
baseclass
PGPush
class
PGPushActualize
global
server
class
PGPushServerAct
identifier
com.pushserver
```
--------------------------------
### Java @UniJSMethod Example (JS Thread)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Extension/android.md
Example of a JavaScript method within a UniModule that executes on the JS thread. It returns a JSONObject synchronously.
```java
//run JS thread
@UniJSMethod (uiThread = false)
public JSONObject testSyncFunc(){
JSONObject data = new JSONObject();
data.put("code", "success");
return data;
}
```
--------------------------------
### Start Host Activity for UniMP Task
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/android-v2.md
Launches a host-defined activity within the UniMP activity stack. This is used when a host dialog needs to appear before the UniMP app.
```Java
Intent intent = new Intent(context, MenuActivity.class);
DCUniMPSDK.getInstance().startActivityForUniMPTask(appid, intent);
```
--------------------------------
### Navigate to Native Page
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Extension/android.md
Navigates from the UniMP environment to a native Android Activity. Requires the UniSDKInstance to get the context.
```JAVA
@UniJSMethod (uiThread = true)
public void gotoNativePage(){
if(mUniSDKInstance != null) {
Intent intent = new Intent(mUniSDKInstance.getContext(), NativePageActivity.class);
mUniSDKInstance.getContext().startActivity(intent);
}
}
```
--------------------------------
### Launch Non-Built-in UniMP App (Before 3.3.7)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/android.md
Releases a .wgt resource package from a specified path to the runtime directory and then launches a non-built-in uni-app. This method is for versions prior to 3.3.7. It requires the wgt path and a callback for completion status.
```Java
String wgtPath = context.getExternalCacheDir().getPath()+"/__UNI__04E3A11.wgt";
DCUniMPSDK.getInstance().releaseWgtToRunPathFromePath("__UNI__04E3A11", wgtPath, new ICallBack() {
@Override
public Object onCallBack(int code, Object pArgs) {
if(code ==1) {//释放wgt完成
try {
DCUniMPSDK.getInstance().openUniMP(context, "__UNI__04E3A11");
} catch (Exception e) {
e.printStackTrace();
}
} else{//释放wgt失败
Toast.makeText(context, "资源释放失败", Toast.LENGTH_SHORT).show();
}
return null;
}
});
```
--------------------------------
### Launch Non-Built-in UniMP App (3.3.7+)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/android.md
Releases a .wgt resource package to the runtime directory and then launches a non-built-in uni-app. This method is for versions 3.3.7 and above. It requires specifying the wgt path and an optional password.
```Java
UniMPReleaseConfiguration uniMPReleaseConfiguration = new UniMPReleaseConfiguration();
uniMPReleaseConfiguration.wgtPath = file.getPath();
uniMPReleaseConfiguration.password = "789456123222";
DCUniMPSDK.getInstance().releaseWgtToRunPath("__UNI__A922B72_minimall", uniMPReleaseConfiguration, new IUniMPReleaseCallBack() {
@Override
public void onCallBack(int code, Object pArgs) {
if(code ==1) {
//释放wgt完成
try {
DCUniMPSDK.getInstance().openUniMP(MainActivity.this, "__UNI__A922B72_minimall");
} catch (Exception e) {
e.printStackTrace();
}
} else{
//释放wgt失败
}
}
});
```
--------------------------------
### Retrieving Arguments in Mini-program
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Demonstrates how to access arguments passed from the host application within the UniMP environment.
```APIDOC
## Accessing Arguments in Mini-program
### Description
This JavaScript snippet shows how to retrieve the arguments passed from the host application using `plus.runtime.arguments`.
### Code
```JavaScript
var arguments = plus.runtime.arguments;
```
```
--------------------------------
### Initialize SDK Engine
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/ios.md
Initialize the SDK engine with launch options in the application's didFinishLaunchingWithOptions method. Debug mode can be enabled by setting 'debug' to YES.
```objective-c
#import "DCUniMP.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 配置参数
NSMutableDictionary *options = [NSMutableDictionary dictionaryWithDictionary:launchOptions];
// 设置 debug YES 会在控制台输出 js log,默认不输出 log,注:需要引入 liblibLog.a 库
[options setObject:[NSNumber numberWithBool:YES] forKey:@"debug"];
// 初始化引擎
[DCUniMPSDKEngine initSDKEnvironmentWithLaunchOptions:options];
return YES;
}
```
--------------------------------
### Get UniMP App ID
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/API/android-v2.md
Retrieves the unique application ID of the currently running UniMP mini-program.
```java
IUniMP.getAppid()
```
--------------------------------
### Handle URL Scheme and Universal Links
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/ios.md
Implement these methods to handle app launches via URL schemes or universal links.
```objective-c
#pragma mark - 如果需要使用 URL Scheme 或 通用链接相关功能,请实现以下方法
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options {
// 通过 url scheme 唤起 App
[DCUniMPSDKEngine application:app openURL:url options:options];
return YES;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray> * _Nullable))restorationHandler {
// 通过通用链接唤起 App
[DCUniMPSDKEngine application:application continueUserActivity:userActivity];
return YES;
}
```
--------------------------------
### Initialize UniMP SDK with Configuration
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/android.md
Initializes the UniMP SDK with custom configurations such as capsule visibility, menu font styles, and custom action sheet items. Ensure no other third-party SDKs are initialized within the uni-app process.
```Java
MenuActionSheetItem item = new MenuActionSheetItem("关于", "gy");
List sheetItems = new ArrayList<>();
sheetItems.add(item);
DCSDKInitConfig config = new DCSDKInitConfig.Builder()
.setCapsule(true)
.setMenuDefFontSize("16px")
.setMenuDefFontColor("#ff00ff")
.setMenuDefFontWeight("normal")
.setMenuActionSheetItems(sheetItems)
.build();
DCUniMPSDK.getInstance().initialize(this, config);
```
```Java
// 非小程序进程(这里的unimp 关键字 可以根据宿主的具体情况进行调整)
if(!RuningAcitvityUtil.getAppName(getBaseContext()).contains("unimp")) {
//请在此处初始化其他三方SDK
... ...
}
```
--------------------------------
### IUniMP.getCurrentPageUrl()
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/API/android-v2.md
Gets the current page URL of the running UniMP application, which can be used for operations like direct page navigation.
```APIDOC
## IUniMP.getCurrentPageUrl()
### Description
Gets the current page URL of the running UniMP application. This can be used for operations such as direct page navigation.
### Parameters
None.
### Response
#### Success Response
- **String** - The URL of the current page within the UniMP application.
```
--------------------------------
### Gradle Configuration for uni小程序 SDK Integration
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/android.md
Configure your app's build.gradle file with essential settings including application ID, target SDK version, ABI filters, aaptOptions, and repository configurations. Add SDK dependencies using flatDir.
```gradle
//必须配置
def mfph = [
//宿主包名
"apk.applicationId" : "xxx.xxx.xxxxx",
]
android {
defaultConfig {
targetSdkVersion 26
ndk {
abiFilters 'x86','armeabi-v7a',"arm64-v8a" //不支持armeabi
}
manifestPlaceholders = mfph
}
//此处配置必须添加 否则无法正确运行
aaptOptions {
additionalParameters '--auto-add-overlay'
//noCompress 'foo', 'bar'
ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
}
}
//导入aar需要的配置
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
//导入SDK相关依赖jar、aar
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: ['*.aar'], dir: 'libs')
//必须添加的依赖
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.alibaba:fastjson:1.2.83'
implementation 'com.facebook.fresco:fresco:1.13.0'
implementation 'com.facebook.fresco:animated-gif:1.13.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'androidx.webkit:webkit:1.3.0'
}
```
--------------------------------
### Close Mini-Program from Within
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/close.md
Call this method from within the mini-program to close itself and return to the host application. This feature is supported starting from version 2.6.3.
```javascript
plus.runtime.quit()
```
--------------------------------
### Launch UniMP App with Arguments
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/android.md
Launches a uni-app and passes custom arguments to it. The arguments are provided as a JSONObject. Refer to the openUniMP method documentation for detailed parameter explanations.
```Java
try {
JSONObject arguments = new JSONObject();
arguments.put("a","1");
IUniMP unimp = DCUniMPSDK.getInstance().openUniMP(context, "__UNI__04E3A11", arguments);
} catch (Exception e) {
e.printStackTrace();
}
```
--------------------------------
### Handle Activity Result in UniModule
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Extension/android.md
Implements the onActivityResult method in a UniModule to receive data returned from a started Activity. Uses a request code and key to identify the result.
```JAVA
public static int REQUEST_CODE = 1000; //数据返回标识code
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_CODE && data.hasExtra("respond")) {
Log.e("TestModule", "原生页面返回----"+data.getStringExtra("respond"));
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
```
--------------------------------
### Configure QQ Feature in properties.xml
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/androidModuleConfig/share.md
Add the QQ module configuration to the assets/data/properties.xml file to enable the Share feature for QQ.
```xml
```
--------------------------------
### Get Current UniMP Page URL
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/API/android-v2.md
Obtains the URL of the current page within the running UniMP mini-program. This can be used for features like direct page navigation.
```java
IUniMP.getCurrentPageUrl()
```
--------------------------------
### iOS Info.plist Configuration for QQ Sharing
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/iOSModuleConfig/share.md
Configure the Info.plist file with your QQ account information. For SDK versions 3.2.0 and above, specific fields must be filled as shown in the provided image.
```plist
qq
AppId
YOUR_APP_ID
```
--------------------------------
### Implement DCUniMPSDKEngineDelegate Methods
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/ios.md
Implement delegate methods to handle custom actions like menu item clicks and to provide a splash screen for mini-programs.
```objective-c
#pragma mark - DCUniMPSDKEngineDelegate
/// DCUniMPMenuActionSheetItem 点击触发回调方法
- (void)defaultMenuItemClicked:(NSString *)appid identifier:(NSString *)identifier {
NSLog(@"标识为 %@ 的 item 被点击了", identifier);
}
/// 返回打开小程序时的自定义闪屏视图
- (UIView *)splashViewForApp:(NSString *)appid {
UIView *splashView = [[[NSBundle mainBundle] loadNibNamed:@"SplashView" owner:self options:nil] lastObject];
return splashView;
}
```
--------------------------------
### Get UniMP App Version Info
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/API/android-v2.md
Retrieves version information for a specified UniMP application. Returns null if the app has not been run. Ensure to handle potential null return values.
```java
JSONObject jsonObject = DCUniMPSDK.getInstance().getAppVersionInfo("__UNI__04E3A11");
if(jsonObject != null) {
Logger.d("__UNI__04E3A11版本信息为"+jsonObject.toString());
}
```
--------------------------------
### Configure AndroidManifest.xml for QQ Share
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseModule/android/share.md
Add permissions and activity configurations for QQ sharing in the AndroidManifest.xml file. Replace '%appid%' with your actual QQ AppID.
```xml
```
```xml
```
--------------------------------
### Configure iOS Extension for Uni-Native Plugins
Source: https://github.com/dcloudio/native-docs/blob/master/docs/NativePlugin/course/package.md
Set up the 'ios-extension.json' file within the native plugin's directory to enable cloud packaging of iOS Extensions. This file specifies the extension's bundle identifier, provisioning profile, and optional plist/entitlement data.
```json
{
"XXX.appex": { //必填,多个iOS Extension需使用多个节点
"identifier": "uni.XXX.ext", //必填,Bundle identifier
"profile": "ios-XXXExt.mobileprovision", //必填,Provisioning Profile,相对于插件目录的路径
"plists": { //可选,合并到iOS Extension的Info.plist中的数据(json格式)
},
"entitlements": { //可选,覆盖iOS Extension的entitlements.plist中的数据(json格式)
}
}
}
```
--------------------------------
### Add Sina Weibo SDK Files
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/androidModuleConfig/share.md
Place the specified .aar files into the project's libs directory for Sina Weibo integration.
```text
SDK\libs | openDefault-12.5.0.aar, share-sina-release.aar
```
--------------------------------
### Configure QQ Sharing in AndroidManifest.xml
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/androidModuleConfig/share.md
Add meta-data for QQ_APPID and configure the AuthActivity and AssistActivity for QQ sharing integration.
```xml
```
--------------------------------
### Open UniMP Mini-Program
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/ios.md
Opens a UniMP mini-program using its App ID and configuration. The completion block provides the instance or an error if opening fails.
```objective-c
/// 打开 uni 小程序
- (IBAction)openUniMP:(id)sender {
// 初始化小程序的配置信息对象
DCUniMPConfiguration *configuration = [[DCUniMPConfiguration alloc] init];
[DCUniMPSDKEngine openUniMP:k_AppId configuration:configuration completed:^(DCUniMPInstance * _Nullable uniMPInstance, NSError * _Nullable error) {
if (uniMPInstance) {
// success
} else {
// error
}
}];
}
```
--------------------------------
### DCUniMPSDK.getInstance().startActivityForUniMPTask(appid, intent)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/API/android-v2.md
Launches an Activity that runs within the UniMP application's task stack. The process remains within the host application, allowing access to host memory data. Closing the launched Activity returns the user to the UniMP application.
```APIDOC
## DCUniMPSDK.getInstance().startActivityForUniMPTask(appid, intent)
### Description
Launches an Activity that runs within the UniMP application's task stack. The process remains within the host application, allowing access to host memory data. Closing the launched Activity returns the user to the UniMP application. Available from v3.2.6.
### Parameters
#### Path Parameters
- **appid** (String) - Required - The unique identifier (appid) of the UniMP application.
- **intent** (android.content.Intent) - Required - An Android Intent object configured with the information of the activity to be launched.
### Response
#### Success Response
- **boolean** - Returns true if the initialization is successful, false otherwise.
### Example
```java
DCUniMPSDK.getInstance().setCapsuleMenuButtonClickCallBack(new IDCUniMPOnCapsuleMenuButtontCallBack() {
@Override
public void menuButtonClicked(String appid) {
Log.e("unimp", appid + " capsule menu button clicked");
Intent intent = new Intent(context, MenuActivity.class);
DCUniMPSDK.getInstance().startActivityForUniMPTask(appid, intent);
}
});
```
```
--------------------------------
### Launch UniMP App to a Specific Page
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/android.md
Launches a uni-app and navigates directly to a specified secondary page using its path. The path parameter allows deep linking into the uni-app. Refer to the openUniMP method documentation for details.
```Java
try {
IUniMP unimp = DCUniMPSDK.getInstance().openUniMP(context,"__UNI__04E3A11", "pages/component/scroll-view/scroll-view");
} catch (Exception e) {
e.printStackTrace();
}
```
--------------------------------
### Getui Maven Repository Configuration (HBuilderX 3.99+)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/androidModuleConfig/oauth.md
Add Getui's Maven repository to the allprojects section of the project's root build.gradle file for HBuilderX version 3.99 and above.
```gradle
allprojects {
repositories {
jcenter()
google()
// 个推的Maven仓库地址
maven {
url 'https://mvn.getui.com/nexus/content/repositories/releases'
}
}
}
```
--------------------------------
### Launch Built-in UniMP App
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/android.md
Launches a built-in uni-app using its application ID. Ensure the application resources are correctly placed in the assets directory.
```Java
try {
IUniMP unimp = DCUniMPSDK.getInstance().openUniMP(context,"__UNI__04E3A11", MySplashView.class);
} catch (Exception e) {
e.printStackTrace();
}
```
--------------------------------
### iOS: Open Mini Program API
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
This is the Objective-C method signature for opening a UniMP mini program on iOS, supporting arguments and a redirect path.
```objective-c
Class DCUniMPSDKEngine
/// 启动小程序
+ (void)openApp:(NSString *)appid
arguments:(NSDictionary * _Nullable)arguments
redirectPath:(NSString * _Nullable)redirectPath;
```
--------------------------------
### Integrate Baidu Location SDK via Gradle
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseModule/android/geolocation.md
Configure your main project's build.gradle file to include the Baidu location SDK libraries.
```gradle
android {
xxxxxxxx
defaultConfig {
xxxxxxxx
}
}
dependencies {
xxxxxxxx
implementation files('libs/baidu-libs-release.aar')
implementation files('libs/geolocation-baidu-release.aar')
}
```
--------------------------------
### iOS Platform - Open App
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/start.md
Launches a UniMP application on iOS, supporting custom arguments and a redirect path.
```APIDOC
## + (void)openApp:(NSString *)appid arguments:(NSDictionary * _Nullable)arguments redirectPath:(NSString * _Nullable)redirectPath;
### Description
Launches a UniMP application with optional arguments and a specified redirect path.
### Method
`+ (void)`
### Parameters
#### Path Parameters
- **appid** (NSString) - Required - The appid of the mini-program.
- **arguments** (NSDictionary) - Optional - Parameters to pass to the mini-program upon startup.
- **redirectPath** (NSString) - Optional - The path of the page to open directly after startup.
```
--------------------------------
### Configure QQ Sharing Permissions in AndroidManifest.xml
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/androidModuleConfig/share.md
Add the MODIFY_AUDIO_SETTINGS permission for QQ sharing functionality.
```xml
```
--------------------------------
### Listen for Events from Host App (Mini Program)
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/Sample/event.md
Use this JavaScript API within the mini program to listen for and receive events sent from the host app. It provides the event name and associated data.
```JavaScript
uni.onNativeEventReceive((event,data)=>{
console.log('接收到宿主App消息:' + event + data);
this.nativeMsg = '接收到宿主App消息 event:' + event + " data: " + data;
})
```
--------------------------------
### iOS Info.plist Configuration for Sina Weibo
Source: https://github.com/dcloudio/native-docs/blob/master/docs/AppDocs/usemodule/iOSModuleConfig/share.md
Configure the Info.plist file with your Sina Weibo account information. For SDK versions 3.2.0 and above, specific fields must be filled as shown in the provided image.
```plist
sinaweibo
AppKey
YOUR_APP_KEY
RedirectURL
YOUR_REDIRECT_URL
NSThirdPartyLoginMeida
com.sina.weibo
```
--------------------------------
### Configure Native Plugins in dcloud_uniplugins.json
Source: https://github.com/dcloudio/native-docs/blob/master/docs/NativePlugin/offline_package/android.md
This JSON file configures native plugins for uni-app. It specifies the plugin name and its corresponding class.
```json
{
"nativePlugins": [
{
"plugins": [
{
"type": "module",
"name": "DCloud-RichAlert",
"class": "uni.dcloud.io.uniplugin_richalert.RichAlertWXModule"
}
]
}
]
}
```
--------------------------------
### Essential uni小程序 SDK Libraries
Source: https://github.com/dcloudio/native-docs/blob/master/docs/UniMPDocs/UseSdk/android.md
Integrate these core libraries for the uni小程序 SDK engine, uni-app engine, and crash log collection. Optional libraries like base_oaid_sdk can be added based on specific needs.
```java
uniMPSDK-V2-release.aar
uniapp-v8-release.aar
breakpad-build-release.aar
sqlite-release.aar
base_oaid_sdk.aar
messaging-release.aar
iBeacon-release.aar
fingerprint-release.aar
contacts-release.aar
Bluetooth-release.aar
android-gif-drawable-release@1.2.23.aar
```