我正在 Swift 3.0 应用程序中实现应用内购买,因此我需要获取应用程序收据以根据 iTunes 商店进行验证。以下是我获取收据的方式:
\n\nfunc getReceipt() -> Data? {\n if Bundle.main.appStoreReceiptURL != nil {\n print("app receipt: \\(Bundle.main.appStoreReceiptURL)")\n do {\n let receiptData = try Data(contentsOf: Bundle.main.appStoreReceiptURL!)\n print(receiptData)\n return receiptData\n } catch {\n print("error converting receipt to Data: \\(error.localizedDescription)")\n }\n }\n return nil\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我的收据 URL 控制台输出是:
\n\n\n\n\n应用程序收据:可选(文件:///Users/dustinspengler/Library/Developer/XCPGDevices/433E8E8F-B781-4ADC-A92D-5CABC28E94D6/data/Containers/Data/Application/C25BE9B6-FB64-4D49-9CF2-9DA371060A7B/StoreKit/收据)
\n
然后它无法将收据转换为Data并打印 catch 语句:
\n\n\n将收据转换为数据时出错:文件 \xe2\x80\x9creceipt\xe2\x80\x9d 无法打开\xe2\x80\x99,因为没有此类文件。
\n
在游乐场、模拟器和真实设备中运行此程序时,我得到完全相同的输出,那么考虑到用户尚未进行应用内购买,这是否意味着该应用程序不存在收据?当阅读苹果的文档时,我的印象是它们总是被创建,无论之前是否购买过。
\n我的childAdded应用中的通知表有一个Firebase 事件监听器,我想在应用程序在后台时触发推送通知.
这是听众:
@objc func observeNotificationsChildAddedBackground() {
self.notificationsBackgroundHandler = FIREBASE_REF!.child("notifications/\(Defaults.userUID!)")
self.notificationsBackgroundHandler!.queryOrdered(byChild: "date").queryLimited(toLast: 99).observe(.childAdded, with: { snapshot in
let newNotificationJSON = snapshot.value as? [String : Any]
if let newNotificationJSON = newNotificationJSON {
let status = newNotificationJSON["status"]
if let status = status as? Int {
if status == 1 {
self.sendPushNotification()
}
}
}
})
}
func sendPushNotification() {
let content = UNMutableNotificationContent()
content.title = "Here is a new notification"
content.subtitle = "new notification push"
content.body = "Someone did something …Run Code Online (Sandbox Code Playgroud) ios firebase swift firebase-cloud-messaging unnotificationrequest
我正在尝试使用nodemailer通过 GoDaddy 配置的自定义电子邮件地址发送电子邮件。这是 c 面板中“自定义配置”页面的屏幕截图:

和我的代码:
const nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'Godaddy',
secureConnection: false,
auth: {
user: 'info@mywebsite.com',
pass: 'mypassword'
}
});
var mailOptions = {
from: 'info@mywebsite.com',
to: 'otheremail@gmail.com',
subject: 'Sending Email using Node.js',
text: 'That was easy!',
html: '<h1>Welcome</h1><p>That was easy!</p>'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
Run Code Online (Sandbox Code Playgroud)
和我的错误日志:
{ Error: connect EHOSTUNREACH 173.201.192.101:25
at Object.exports._errnoException (util.js:1012:11)
at exports._exceptionWithHostPort (util.js:1035:20)
at …Run Code Online (Sandbox Code Playgroud) 我正在使用React Native带有徽标和2个输入的基本登录名:
//import liraries
import React, { Component } from 'react';
import { View, Text, StyleSheet, Image } from 'react-native';
// create a component
class Login extends Component {
render() {
const imageURL = require('./images/CircleLogo.png');
return (
<View style={styles.container}>
<View style={styles.loginContainer}>
<Image resizeMode="contain" style={styles.logo} source={imageURL} />
</View>
<View style={styles.formContainer}>
<LoginForm />
</View>
</View>
);
}
}
// define your styles
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'aliceblue',
},
loginContainer:{
alignItems: 'center',
flexGrow: 1,
justifyContent: 'center' …Run Code Online (Sandbox Code Playgroud) 直接问题:
你如何以编程方式在Swift 2.0中点击UIButton?
例: UIButton.tap()
解释为什么我不能直接调用按钮点击功能:
我目前正在使用AKSwiftSlideMenu(https://github.com/ashishkakkad8/AKSwiftSlideMenu)(https://www.cocoacontrols.com/controls/akswiftslidemenu)来创建菜单.这是通过将菜单视图控制器作为子视图添加到主视图控制器来实现的.
let menuVC : BackTableViewController = self.storyboard!.instantiateViewControllerWithIdentifier("backTableViewController") as! BackTableViewController
menuVC.btnMenu = sender
self.view.addSubview(menuVC.view)
self.addChildViewController(menuVC)
Run Code Online (Sandbox Code Playgroud)
正如你所看到的btnMenu,这是一个UIButton,正在被传递给menuVC.在两个视图控制器上具有相同的按钮允许onSlideMenuButtonPressed(sender : UIButton)在家庭视图控制器中的单个功能来处理该视图的呈现menuVC.我正在创建的菜单中的一个选项是"注销"按钮,UIAlertViewController其中显示询问用户是否要注销的按钮.以下是我的"是"按钮处理程序的代码menuVC:
logOutAlert.addAction(UIAlertAction(title:"Yes", style: .Default, handler: { action in
self.btnMenu.touchInside
CURRENT_USER.unauth()
NSUserDefaults.standardUserDefaults().setValue(nil, forKey: "uid")
print("User logged out")
CurrentUser.checkIfUserIsLoggedIn()
}))
Run Code Online (Sandbox Code Playgroud)
我试图点击该touchInside方法的按钮(当然是不对的),以解雇menuVC.是否存在UIButton.tap()等效或访问btnMenu onSlideMenuButtonPressed(sender : UIButton)函数的方法?
旁注:我想要创建一个homeViewControllerDelegate对象,menuVC以便onSlideMenuButtonPressed(sender : UIButton)直接调用它,这可能有用,但它似乎是一个圆形的方式,因为btnMenu …
ios ×2
swift ×2
css ×1
firebase ×1
nodemailer ×1
react-native ×1
reactjs ×1
receipt ×1
uibutton ×1