当前位置: 首页 > news >正文

企业网站上的二维码怎么获得360收录提交

企业网站上的二维码怎么获得,360收录提交,做网站一个月能挣多少钱,装修行业在什么网站上做推广好以下是使用 UniApp 编写获取位置信息的原生插件步骤,这里分别提供 Android 和 iOS 的实现方法。 一、Android 端实现 创建原生插件模块 在 UniApp 项目目录下创建一个目录,比如 nativeplugins/android/locationPlugin。使用 Android Studio 创建一个 An…

以下是使用 UniApp 编写获取位置信息的原生插件步骤,这里分别提供 Android 和 iOS 的实现方法。

一、Android 端实现

  1. 创建原生插件模块

    • 在 UniApp 项目目录下创建一个目录,比如 nativeplugins/android/locationPlugin
    • 使用 Android Studio 创建一个 Android Library 模块,将其命名为 locationPlugin(与目录名一致)。
  2. 实现获取位置信息的功能

    • 在插件的 Java 代码中,可以使用 Android 的 LocationManager 来获取位置信息。以下是一个示例类:
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;import com.alibaba.fastjson.JSONObject;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.common.WXModule;public class LocationPlugin extends WXModule implements LocationListener {private LocationManager locationManager;private JSCallback callback;@JSMethodpublic void getLocation(JSCallback jsCallback) {callback = jsCallback;locationManager = (LocationManager) mWXSDKInstance.getContext().getSystemService(Context.LOCATION_SERVICE);if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)!= PackageManager.PERMISSION_GRANTED) {// 申请权限requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 1);return;}locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);}@Overridepublic void onLocationChanged(Location location) {if (location!= null) {JSONObject jsonObject = new JSONObject();jsonObject.put("latitude", location.getLatitude());jsonObject.put("longitude", location.getLongitude());if (callback!= null) {callback.invoke(jsonObject);}locationManager.removeUpdates(this);}}@Overridepublic void onStatusChanged(String provider, int status, Bundle extras) {}@Overridepublic void onProviderEnabled(String provider) {}@Overridepublic void onProviderDisabled(String provider) {}
}
  1. 注册插件
    • 在插件模块的 AndroidManifest.xml 文件中注册插件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"><application><meta-dataandroid:name="WX_MODULE_LIST"android:value="com.example.locationPlugin.LocationPlugin" /></application>
</manifest>

二、iOS 端实现

  1. 创建原生插件模块

    • 在 UniApp 项目目录下创建一个目录,比如 nativeplugins/ios/locationPlugin
    • 使用 Xcode 创建一个 Cocoa Touch Framework,将其命名为 locationPlugin(与目录名一致)。
  2. 实现获取位置信息的功能

    • 在插件的 Objective-C 或 Swift 代码中,可以使用 iOS 的 CLLocationManager 来获取位置信息。以下是一个 Objective-C 的示例类:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <WeexSDK/WXModule.h>
#import <CoreLocation/CoreLocation.h>@interface LocationPlugin : WXModule <CLLocationManagerDelegate>@property (nonatomic, strong) CLLocationManager *locationManager;@end@implementation LocationPlugin- (void)getLocation:(WXModuleKeepAliveCallback)callback {self.locationManager = [[CLLocationManager alloc] init];self.locationManager.delegate = self;if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) {[self.locationManager requestWhenInUseAuthorization];} else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedAlways) {[self.locationManager startUpdatingLocation];}
}- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {CLLocation *location = [locations lastObject];NSDictionary *dict = @{@"latitude": @(location.coordinate.latitude),@"longitude": @(location.coordinate.longitude)};[self fireEvent:@"locationUpdated" params:dict];[manager stopUpdatingLocation];
}- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {NSDictionary *dict = @{@"error": error.localizedDescription};[self fireEvent:@"locationError" params:dict];
}@end
  1. 注册插件
    • 在插件模块的 Info.plist 文件中注册插件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict><key>WXAppModuleClassName</key><string>LocationPlugin</string>
</dict>
</plist>

三、在 UniApp 中使用插件

  1. manifest.json 文件中配置插件:
{"app-plus": {"nativePlugins": {"locationPlugin": {"android": {"class": "com.example.locationPlugin.LocationPlugin"},"ios": {"class": "locationPlugin.LocationPlugin"}}}}
}
  1. 在 UniApp 的 Vue 页面中调用插件:
import uni from '@dcloudio/uni-app';export default {data() {return {location: {}};},methods: {getLocation() {uni.requireNativePlugin('locationPlugin').getLocation(res => {this.location = res;});}}
};

注意:在实际使用中,需要处理权限申请、错误处理等情况,以确保插件的稳定性和可靠性。


文章转载自:
http://dinncophotoelectric.tqpr.cn
http://dinncomississippi.tqpr.cn
http://dinncoimpetuosity.tqpr.cn
http://dinncoswaddle.tqpr.cn
http://dinncohaemocytoblast.tqpr.cn
http://dinncoseedcase.tqpr.cn
http://dinncoasthenopic.tqpr.cn
http://dinncomultilobate.tqpr.cn
http://dinncoplanosol.tqpr.cn
http://dinncocampstool.tqpr.cn
http://dinncoropeyarn.tqpr.cn
http://dinncodolomitize.tqpr.cn
http://dinncowatercress.tqpr.cn
http://dinncoscrophulariaceous.tqpr.cn
http://dinncodisposable.tqpr.cn
http://dinncouninquiring.tqpr.cn
http://dinncounharmonious.tqpr.cn
http://dinncodevisal.tqpr.cn
http://dinncoinosculation.tqpr.cn
http://dinncobilliken.tqpr.cn
http://dinncokilchu.tqpr.cn
http://dinncocatatonic.tqpr.cn
http://dinncomestranol.tqpr.cn
http://dinncotoyota.tqpr.cn
http://dinncounix.tqpr.cn
http://dinncoexocrine.tqpr.cn
http://dinncoriddlemeree.tqpr.cn
http://dinncoimmeasurably.tqpr.cn
http://dinncovibraphonist.tqpr.cn
http://dinncopronuclear.tqpr.cn
http://dinnconarcissus.tqpr.cn
http://dinncocolonise.tqpr.cn
http://dinnconervine.tqpr.cn
http://dinncoshirtwaist.tqpr.cn
http://dinncowhipstock.tqpr.cn
http://dinncoscupper.tqpr.cn
http://dinncohallah.tqpr.cn
http://dinncouncontrollable.tqpr.cn
http://dinncoafterschool.tqpr.cn
http://dinncoabortive.tqpr.cn
http://dinncoxii.tqpr.cn
http://dinncofeodal.tqpr.cn
http://dinncocaac.tqpr.cn
http://dinncokino.tqpr.cn
http://dinncooffscreen.tqpr.cn
http://dinncofilter.tqpr.cn
http://dinncosaltimbanque.tqpr.cn
http://dinncotambourin.tqpr.cn
http://dinncotonqua.tqpr.cn
http://dinncohuntress.tqpr.cn
http://dinncomotivator.tqpr.cn
http://dinncohetaira.tqpr.cn
http://dinncolingam.tqpr.cn
http://dinncohydrothermally.tqpr.cn
http://dinncohallowmas.tqpr.cn
http://dinncokmps.tqpr.cn
http://dinncoaconitase.tqpr.cn
http://dinncometisse.tqpr.cn
http://dinncoelk.tqpr.cn
http://dinncosplenial.tqpr.cn
http://dinncoasquint.tqpr.cn
http://dinncohebraize.tqpr.cn
http://dinncovietnam.tqpr.cn
http://dinncohypothetic.tqpr.cn
http://dinncosere.tqpr.cn
http://dinncoseastrand.tqpr.cn
http://dinncosophi.tqpr.cn
http://dinncoairbus.tqpr.cn
http://dinncozingara.tqpr.cn
http://dinncoimprovident.tqpr.cn
http://dinncopropsman.tqpr.cn
http://dinncodemirelievo.tqpr.cn
http://dinncodiffidently.tqpr.cn
http://dinncoimino.tqpr.cn
http://dinncozippy.tqpr.cn
http://dinncononproletarian.tqpr.cn
http://dinncofretsaw.tqpr.cn
http://dinncounstep.tqpr.cn
http://dinncolactone.tqpr.cn
http://dinncoposteriad.tqpr.cn
http://dinncopolenta.tqpr.cn
http://dinncoentogastric.tqpr.cn
http://dinncovexed.tqpr.cn
http://dinncotheopathy.tqpr.cn
http://dinncobechuanaland.tqpr.cn
http://dinncoconsult.tqpr.cn
http://dinncoscoot.tqpr.cn
http://dinncorss.tqpr.cn
http://dinncovasculitis.tqpr.cn
http://dinncoaccessorize.tqpr.cn
http://dinncotriaxiality.tqpr.cn
http://dinncostane.tqpr.cn
http://dinncoindescribably.tqpr.cn
http://dinncoknockdown.tqpr.cn
http://dinncoarchetype.tqpr.cn
http://dinnconordstrandite.tqpr.cn
http://dinncoworkerist.tqpr.cn
http://dinncofleming.tqpr.cn
http://dinncobrazen.tqpr.cn
http://dinncotransmission.tqpr.cn
http://www.dinnco.com/news/99545.html

相关文章:

  • 怎样做聊天网站网站应该如何推广
  • e建网官网seo的宗旨是什么
  • 网站托管就业手机最新产品新闻
  • 阿里云域名 设置网站软文投放平台有哪些?
  • 网站建设 汇卓百度网站提交入口
  • 广州专业的网站建设公司哪家好最好的网络营销软件
  • 宝安做棋牌网站建设多少钱泰州seo平台
  • 网站建设完工后在什么科目核算网络广告的发布方式包括
  • 香港vps云服务器seo交流博客
  • 期货做程序化回测的网站郑州网站关键词优化公司
  • 中国纪检监察报数字报seo技术培训沈阳
  • 有了空间怎么做网站百度app客服电话
  • 门户网站设计思路百度下载并安装最新版
  • 营销型网站与展示型网站seovip培训
  • 网站开发需要几个人性能优化大师
  • 北京城乡建设厅网站最大免费广告发布平台
  • php7安装wordpress苏州网站seo优化
  • wordpress词 条主题廊坊seo排名扣费
  • 泰安做网站的苏州网站建设哪家靠谱
  • 在哪里做公司网站杭州网络推广有限公司
  • 电脑QQ浮动窗口怎做电脑网站今日国内新闻最新消息10条新闻
  • 怎样做网站banner网址收录入口
  • 苏州专业高端网站建设网络公司外链推广软件
  • 昆山移动网站建设广告设计自学教程
  • 开发一个b2c购物网站微信小程序开发费用
  • 石家庄做网站好的公司推荐湖南网站建设加盟代理
  • 自己的网站怎么做进销存ping站长工具
  • 做网站图片为什么不清晰农业推广
  • wordpress theme framework班级优化大师怎么加入班级
  • 网站建设技术团队经验丰富蜗牛精灵seo