Skip to content

Commit

Permalink
[Enhancement]: Deleting the temporary generated payload file after se…
Browse files Browse the repository at this point in the history
…nding the push notification (#16)
  • Loading branch information
engali94 authored Apr 14, 2020
1 parent 34c890d commit 3d98585
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/PoesCore/Send.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ struct Send: ParsableCommand, ShellInjectable {
Log.debug("Generated payload:\n\n\(jsonString)\n")
}

let url = Foundation.URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent("payload.json")
FileManager.default.createFile(atPath: url.path, contents: jsonData, attributes: nil)
let tempUrl = NSTemporaryDirectory()
let payloadUrl = Foundation.URL(fileURLWithPath: tempUrl, isDirectory: true).appendingPathComponent("payload.json")
FileManager.default.createFile(atPath: payloadUrl.path, contents: jsonData, attributes: nil)

Log.message("Sending push notification...")
Self.shell.execute(.push(bundleIdentifier: bundleIdentifier, payloadPath: url.path))
Self.shell.execute(.push(bundleIdentifier: bundleIdentifier, payloadPath: payloadUrl.path))
Log.message("Push notification sent successfully")
try FileManager.default.removeItem(at: payloadUrl)
}
}

0 comments on commit 3d98585

Please sign in to comment.