移動應用開發服務端工具庫 mobile-toolkit
Java 的移動應用開發服務端工具庫, 提供了Apple push,應用內支付校驗, Amazon的aws的幾個服務的調用.
在現在移動應用(ios,android)的開發過程中,經常會需要調用Apple 的push服務以及應用內支付校驗的功能,現有的一些sdk使用起來都不是很方便, 所以這里包裝了一個更加簡單更加方便的java庫. 例如apple 的push服務其實就是包裝了 APNS .
Amazon的S3存儲和Mail功能在開發海外的項目中也是經常使用到的云服務,Amazon的SDK本身已經很全面,這里也僅僅是包裝簡化其使用方式.
Enjoy it!
## feature 1. APNS Apple push notification service
//setup apns by your keystore, key password and production ,false will use sandbox env
ApnsTools apnsTools = new DefaultApnsTools("aps.p12", "password", false);
apnsTools.alert("message", "device token");
//async apns , should set async thread number
AsyncApnsTools asyncApnsTools = new DefaultAsyncApnsTools("aps.p12", "password", false, 12);
asyncApnsTools.alert("message", "device token");
// you can setup a monitor for async apns tool.such as log monitor for print push result log. 2 is the log interval. TimeUnit is second
AsyncNotificationMonitor monitor = new LogNotificationMonitor(2, asyncApnsTools);
Suggest config this in spring:
<bean id="apnsTools" class="mobi.app.toolkit.apple.impl.DefaultApnsTools">
<constructor-arg index="0" value="${aps.key}"/>
<constructor-arg index="1" value="${aps.password}"/>
<constructor-arg index="2" value="${aps.production}"/>
</bean>
<bean id="asyncApnsTools" class="mobi.app.toolkit.apple.impl.DefaultAsyncApnsTools">
<constructor-arg index="0" value="${aps.key}"/>
<constructor-arg index="1" value="${aps.password}"/>
<constructor-arg index="2" value="${aps.production}"/>
<constructor-arg index="3" value="${aps.threadNumber}"/>
</bean>
<bean id="logMonitor" class="mobi.app.toolkit.apple.impl.LogNotificationMonitor">
<constructor-arg index="0" value="2"/>
<constructor-arg index="1" ref="asyncApnsTools"/>
</bean>
2. IAP Apple in app pay
//Setup iap tools, false will use sandbox env
IapTools iapTools = new DefaultIapTools(false);
IapReceipt receipt = iapTools.validate("your pay receipt");
System.out.print(receipt.getStatus());
Suggest config this in spring:
<bean id="iapTools" class="mobi.app.toolkit.apple.impl.DefaultIapTools">
<constructor-arg value="${iap.production}"/>
</bean>
3. AWS S3 Amazon s3
AwsS3Tools s3Tools = new DefaultS3Tools("your accessKey", "your accessSecret");
String url = s3Tools.upload("bucket", "key", new byte[]{}, "image/png");
System.out.print(url);
Suggest config this in spring:
<bean id="amazonS3Client" class="mobi.app.toolkit.aws.impl.DefaultS3Tools">
<constructor-arg index="0" value="${s3.accessKey}"/>
<constructor-arg index="1" value="${s3.accessSecret}"/>
</bean>
4. AWS Mail Amazon mail
AwsMailTools mailTools = new DefaultMailTools("your accessKey", "your accessSecret", "your admin mail");
mailTools.sendMail("to address", "title", "body");
Suggest config this in spring:
<bean id="awsMailTools" class="mobi.app.toolkit.aws.impl.DefaultMailTools">
<constructor-arg index="0" value="${aws.accessKey}"/>
<constructor-arg index="1" value="${aws.accessSecret}"/>
<constructor-arg index="2" value="${aws.adminMail}"/>
</bean>
本文由用戶 openkk 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!