反应原生 AEP 位置扩展
@adobe/react-native-aepplaces 是iOS和Android周围的包装器 Adobe 体验平台扩展 允许与 React Industrial 应用程序融合。 启用Adobe Places的功能完全通过下面所记录的JavaScript提供.
同伴依赖关系
Adobe体验平台优化扩展有以下对等依赖性,在安装优化扩展前必须安装: 1
安装
见 所需经费和安装 主页上的指令
安装 @adobe/react-native-aepplaces 软件包 :
国家预防机制:
npm install @adobe/react-native-aepplaces
亚伦:
yarn add @adobe/react-native-aepplaces
使用量
以 SDK 初始化 :
要初始化SDK,使用以下方法: 1
参考根 读取 关于SDK设置的更多信息.
导入扩展名 :
import {
Places,
PlacesAuthStatus,
PlacesGeofence,
PlacesGeofenceTransitionType,
PlacesLocation,
PlacesPOI,
} from "@adobe/react-native-aepplaces";
API 参考
获取扩展版本 :
语法
extensionVersion(): Promise<string>
示例
const version = await Places.extensionVersion();
console.log(`AdobeExperienceSDK: Places version: ${version}`);
获取附近关注点:
语法
getNearbyPointsOfInterest(location, <limit>): Promise<Array<PlacesPOI>>
示例
let location = new PlacesLocation(<latitude>, <longitude>, <optional altitude>, <optional speed>, <optional accuracy>);
try {
const pois = await Places.getNearbyPointsOfInterest(location, <limit>);
console.log(`AdobeExperienceSDK: Places pois: ${pois}`)
} catch(error) {
console.log(`AdobeExperienceSDK: Places error: ${error}`
}
过程地缘:
语法
processGeofence(geofence, <transitionType>): void
示例
// create a geofence
let geofence = new PlacesGeofence("geofence Identifier", <latitude>, <longitude>, <radius>, <optional expiration-duration>);
Places.processGeofence(geofence, PlacesGeofenceTransitionType.ENTER);
Places.processGeofence(geofence, PlacesGeofenceTransitionType.EXIT);
获取当前利益点 :
语法
getCurrentPointsOfInterest(): Promise<Array<PlacesPOI>>
示例
const pois = await Places.getCurrentPointsOfInterest();
console.log('AdobeExperienceSDK: Places pois: ' + pois);
);
获取最后已知位置
语法
getLastKnownLocation(): Promise<PlacesLocation>
示例
const location = await Places.getLastKnownLocation();
console.log('AdobeExperienceSDK: Places location: ' + location)
);
清除
语法
clear(): void
示例
Places.clear();
设定授权状态 :
语法
setAuthorizationStatus(authStatus?: PlacesAuthStatus): void;
示例
Places.setAuthorizationStatus(PlacesAuthStatus.ALWAYS);
Places.setAuthorizationStatus(PlacesAuthStatus.DENIED);
Places.setAuthorizationStatus(PlacesAuthStatus.RESTRICTED);
Places.setAuthorizationStatus(PlacesAuthStatus.WHEN_IN_USE);
Places.setAuthorizationStatus(PlacesAuthStatus.UNKNOWN);